Skip to content

Commit

Permalink
Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnie57 committed Oct 10, 2024
1 parent 619357a commit 6d5d0cd
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/react-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"scripts": {
"generate": "node ./generator/index.js",
"build": "pnpm run fix && preconstruct build",
"test:integration": "jest -i",
"fix": "pnpm run format:fix && pnpm run lint:fix",
"format": "prettier --check .",
"format:fix": "prettier --write .",
Expand Down
16 changes: 16 additions & 0 deletions packages/react-sdk/test/integration/useIpAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,20 @@ describe("useIpAccount Functions", () => {
);
});
});

it("should success when call getIpAccountNonce", async () => {
await act(async () => {
await expect(ipAccountHook.getIpAccountNonce(ipId)).resolves.toEqual(
expect.any(String)
);
});
});

it("should success when call getToken", async () => {
await act(async () => {
await expect(ipAccountHook.getToken(ipId)).resolves.toEqual(
expect.any(String)
);
});
});
});
1 change: 1 addition & 0 deletions packages/react-sdk/test/integration/useIpAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe("useIpAsset Functions", () => {
});

it("should success when registering derivative with license tokens", async () => {
console.log("tokenId", "mockERC721Address", mockERC721Address);
const tokenId = await getTokenId();
let ipId: Address;
let licenseTokenId: bigint;
Expand Down
40 changes: 36 additions & 4 deletions packages/react-sdk/test/integration/useLicense.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { renderHook } from "@testing-library/react";
import { Hex } from "viem";
import { Hex, zeroAddress } from "viem";
import { act } from "react";

import { useIpAsset, useLicense } from "../../src";
Expand All @@ -13,7 +13,39 @@ describe("useLicense Functions", () => {
const {
result: { current: ipAssetHook },
} = renderHook(() => useIpAsset(), { wrapper: Wrapper });
describe("registering license with different types", () => {
describe("should success when register license with generic license terms", () => {
it("should success when registerPILTerms", async () => {
await act(async () => {
await expect(
licenseHook.registerPILTerms({
defaultMintingFee: "1",
currency: mockERC20Address,
transferable: false,
royaltyPolicy: zeroAddress,
commercialUse: false,
commercialAttribution: false,
commercializerChecker: zeroAddress,
commercializerCheckerData: "0x",
commercialRevShare: 0,
derivativesAllowed: false,
derivativesAttribution: false,
derivativesApproval: false,
derivativesReciprocal: false,
uri: "",
expiration: "",
commercialRevCeiling: "",
derivativeRevCeiling: "",
txOptions: {
waitForTransaction: true,
},
})
).resolves.toEqual(
expect.objectContaining({
licenseTermsId: expect.any(BigInt),
})
);
});
});
it("should success when register license with non commercial social remixing PIL", async () => {
await act(async () => {
await expect(
Expand All @@ -34,7 +66,7 @@ describe("useLicense Functions", () => {
await act(async () => {
await expect(
licenseHook.registerCommercialUsePIL({
mintingFee: "1",
defaultMintingFee: "1",
currency: mockERC20Address,
txOptions: {
waitForTransaction: true,
Expand All @@ -52,7 +84,7 @@ describe("useLicense Functions", () => {
await act(async () => {
await expect(
licenseHook.registerCommercialRemixPIL({
mintingFee: "1",
defaultMintingFee: "1",
commercialRevShare: 100,
currency: mockERC20Address,
txOptions: {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/test/integration/useRoyalty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("useRoyalty Functions", () => {
return await act(async () => {
return (
await licenseHook.registerCommercialUsePIL({
mintingFee: "1",
defaultMintingFee: "1",
currency: mockERC20Address,
txOptions: {
waitForTransaction: true,
Expand Down
6 changes: 2 additions & 4 deletions packages/react-sdk/test/integration/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
defineChain,
} from "viem";

export const RPC = "https://testnet.storyrpc.io";
export const RPC = "https://story-testnet.aura.network";
export const mockERC721Address = "0x322813fd9a801c5507c9de605d63cea4f2ce6c44";
export const mockERC20Address = "0x91f6F05B08c16769d3c85867548615d270C42fC7";
export const iliad = defineChain({
Expand Down Expand Up @@ -46,9 +46,7 @@ export const walletClient = createWalletClient({
account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as Hex),
});

export const getTokenId = async (
nftContract?: Address
): Promise<number | undefined> => {
export const getTokenId = async (): Promise<number | undefined> => {
const { request } = await publicClient.simulateContract({
abi: [
{
Expand Down

0 comments on commit 6d5d0cd

Please sign in to comment.