Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tests #26

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 22 additions & 35 deletions tests/api/licenses/licenses-ip-terms.get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,32 @@ const endpoint = "./licenses/ip/terms";

test.describe("Get LicenseIpTerm @Licenses", () => {
test("query with id param", async ({ request, licensesIpTerms }) => {
const params = [
{ licenseIpTermId: licensesIpTerms[1].id, exists: true },
{ licenseIpTermId: "0", exists: false },
];
for (const { licenseIpTermId, exists } of params) {
await test.step(`Query with licenseIpTermId ${licenseIpTermId}`, async () => {
const response = await request.get(endpoint + `/${licenseIpTermId}`);
expect(response.status()).toBe(200);
const licenseIpTermId = licensesIpTerms[1].id;
const response = await request.get(endpoint + `/${licenseIpTermId}`);
expect(response.status()).toBe(200);

const { errors, data } = await response.json();
expect(errors).toBeUndefined();
if (exists) {
expect(data.id).toBe(licenseIpTermId);
expect.soft(typeof data.ipId).toBe("string");
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.licenseTermsId).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.ipId).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.licenseTermsId).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
} else {
expect(data).toMatchObject({
id: "",
ipId: "",
licenseTemplate: "",
licenseTermsId: "",
blockNumber: "",
blockTime: "",
});
}
});
}
const { errors, data } = await response.json();
expect(errors).toBeUndefined();
expect(data.id).toBe(licenseIpTermId);
expect.soft(typeof data.ipId).toBe("string");
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.licenseTermsId).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.ipId).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.licenseTermsId).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
});

test("query with non-exist id param", async ({ request }) => {
const response = await request.get(endpoint + "/0");
expect(response.status()).toBe(404);
});

test("query with no param", async ({ request }) => {
const response = await request.get(endpoint);
expect(response.status()).toBe(404);
});
});
});
60 changes: 27 additions & 33 deletions tests/api/licenses/licenses-mintingfees.get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
import { test, expect } from "../fixtures/base";

const endpoint = "./licenses/mintingfees";
const endpoint = "./licenses/mintingfees";

test.describe("Get a Minting Fee @Licenses Minting Fees", async () => {
test("Should return Licenses Minting Fees detail", async ({
request,
licensesMintingfees,
}) => {
const params = [
{ licenseMintingFeeId: licensesMintingfees[1].id, exists: true },
{ licenseMintingFeeId: "0x78b3264eaf8030999", exists: false },
];
for (const { licenseMintingFeeId, exists } of params) {
await test.step(`Query with licenseMintingFeeId ${licenseMintingFeeId}`, async () => {
const response = await request.get(
endpoint + `/${licenseMintingFeeId}`
);
expect(response.status()).toBe(200);
const licenseMintingFeeId = licensesMintingfees[1].id;
const response = await request.get(endpoint + `/${licenseMintingFeeId}`);
expect(response.status()).toBe(200);

const { errors, data } = await response.json();
expect(errors).toBeUndefined();
if (exists) {
expect(data.id).toBe(licenseMintingFeeId);
expect(typeof data.token).toBe("string");
expect(typeof data.payer).toBe("string");
expect(typeof data.amount).toBe("string");
expect(typeof data.receiverIpId).toBe("string");
expect(typeof data.blockNumber).toBe("string");
expect(typeof data.blockTimestamp).toBe("string");
expect(data.id).toBeTruthy();
expect(data.token).toBeTruthy();
expect(data.payer).toBeTruthy();
expect(data.amount).toBeTruthy();
expect(data.receiverIpId).toBeTruthy();
expect(data.blockNumber).toBeTruthy();
expect(data.blockTimestamp).toBeTruthy();
} else {
expect(data.id).toBeFalsy();
}
});
}
const { errors, data } = await response.json();
expect(errors).toBeUndefined();
expect(data.id).toBe(licenseMintingFeeId);
expect.soft(typeof data.token).toBe("string");
expect.soft(typeof data.payer).toBe("string");
expect.soft(typeof data.amount).toBe("string");
expect.soft(typeof data.receiverIpId).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTimestamp).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.token).toBeTruthy();
expect.soft(data.payer).toBeTruthy();
expect.soft(data.amount).toBeTruthy();
expect.soft(data.receiverIpId).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTimestamp).toBeTruthy();
});

test("Should return 404 for non-exist licenseMintingFeeId", async ({
request,
}) => {
const response = await request.get(endpoint + "/0x78b3264eaf8030999");
expect(response.status()).toBe(404);
});

test("Should return null for no licenseMintingFeeId", async ({ request }) => {
Expand Down
52 changes: 20 additions & 32 deletions tests/api/licenses/licenses-templates.get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,27 @@ const endpoint = "./licenses/templates";

test.describe("Get LicenseTemplate @Licenses", () => {
test("query with id param", async ({ request, licensesTemplates }) => {
const params = [
{ licenseTemplateId: licensesTemplates[0].id, exists: true },
{ licenseTemplateId: "1", exists: false },
];
for (const { licenseTemplateId, exists } of params) {
await test.step(`Query with licenseTemplateId ${licenseTemplateId}`, async () => {
const response = await request.get(endpoint + `/${licenseTemplateId}`);
expect(response.status()).toBe(200);
const licenseTemplateId = licensesTemplates[0].id;
const response = await request.get(endpoint + `/${licenseTemplateId}`);
expect(response.status()).toBe(200);

const { errors, data } = await response.json();
expect(errors).toBeUndefined();
if (exists) {
expect(data.id).toBe(licenseTemplateId);
expect.soft(typeof data.name).toBe("string");
expect.soft(typeof data.metadataUri).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.name).toBeTruthy();
expect.soft(data.metadataUri).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
} else {
expect(data).toMatchObject({
id: "",
name: "",
metadataUri: "",
blockNumber: "",
blockTime: "",
});
}
});
}
const { errors, data } = await response.json();
expect(errors).toBeUndefined();
expect(data.id).toBe(licenseTemplateId);
expect.soft(typeof data.name).toBe("string");
expect.soft(typeof data.metadataUri).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.name).toBeTruthy();
expect.soft(data.metadataUri).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
});

test("query with non-exist id param", async ({ request }) => {
const response = await request.get(endpoint + "/0");
expect(response.status()).toBe(404);
});

test("query with no param", async ({ request }) => {
Expand Down
54 changes: 21 additions & 33 deletions tests/api/licenses/licenses-terms.get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,31 @@ const endpoint = "./licenses/terms";

test.describe("Get LicenseTerm @Licenses", () => {
test("query with id param", async ({ request, licensesTerms }) => {
const params = [
{ licenseTermId: licensesTerms[1].id, exists: true },
{ licenseTermId: "0", exists: false },
];
for (const { licenseTermId, exists } of params) {
await test.step(`Query with licenseTermId ${licenseTermId}`, async () => {
const response = await request.get(endpoint + `/${licenseTermId}`);
expect(response.status()).toBe(200);
const licenseTermId = licensesTerms[1].id;
const response = await request.get(endpoint + `/${licenseTermId}`);
expect(response.status()).toBe(200);

const { errors, data } = await response.json();
expect(errors).toBeUndefined();
if (exists) {
expect(data.id).toBe(licenseTermId);
expect.soft(Array.isArray(data.licenseTerms)).toBeTruthy();
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.licenseTerms).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
} else {
expect(data).toMatchObject({
id: "",
licenseTerms: [],
licenseTemplate: "",
blockNumber: "",
blockTime: "",
});
}
});
}
const { errors, data } = await response.json();
expect(errors).toBeUndefined();
expect(data.id).toBe(licenseTermId);
expect.soft(Array.isArray(data.licenseTerms)).toBeTruthy();
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.licenseTerms).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
});

test("query with non-exist id param", async ({ request }) => {
const response = await request.get(endpoint + "/0");
expect(response.status()).toBe(404);
});

test("query with no param", async ({ request }) => {
const response = await request.get(endpoint);
expect(response.status()).toBe(404);
});
});
});
82 changes: 32 additions & 50 deletions tests/api/licenses/licenses-tokens.get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,39 @@ const endpoint = "./licenses/tokens";

test.describe("Get LicenseToken @Licenses", () => {
test("query with id param", async ({ request, licensesTokens }) => {
const params = [
{ licenseTokenId: licensesTokens[1].id, exists: true },
{ licenseTokenId: "-1", exists: false },
];
for (const { licenseTokenId, exists } of params) {
await test.step(`Query with licenseTokenId ${licenseTokenId}`, async () => {
const response = await request.get(endpoint + `/${licenseTokenId}`);
expect(response.status()).toBe(200);
const licenseTokenId = licensesTokens[1].id;
const response = await request.get(endpoint + `/${licenseTokenId}`);
expect(response.status()).toBe(200);

const { errors, data } = await response.json();
expect(errors).toBeUndefined();
if (exists) {
expect(data.id).toBe(licenseTokenId);
expect.soft(typeof data.licensorIpId).toBe("string");
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.licenseTermsId).toBe("string");
expect.soft(typeof data.transferable).toBe("string");
expect.soft(typeof data.owner).toBe("string");
expect.soft(typeof data.mintedAt).toBe("string");
expect.soft(typeof data.expiresAt).toBe("string");
expect.soft(typeof data.burntAt).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.licensorIpId).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.licenseTermsId).toBeTruthy();
expect.soft(data.transferable).toBeTruthy();
expect.soft(data.owner).toBeTruthy();
expect.soft(data.mintedAt).toBeTruthy();
expect.soft(data.expiresAt).toBeTruthy();
expect.soft(data.burntAt).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
} else {
expect(data).toMatchObject({
id: "",
licensorIpId: "",
licenseTemplate: "",
licenseTermsId: "",
transferable: "",
owner: "",
mintedAt: "",
expiresAt: "",
burntAt: "",
blockNumber: "",
blockTime: "",
});
}
});
}
const { errors, data } = await response.json();
expect(errors).toBeUndefined();
expect(data.id).toBe(licenseTokenId);
expect.soft(typeof data.licensorIpId).toBe("string");
expect.soft(typeof data.licenseTemplate).toBe("string");
expect.soft(typeof data.licenseTermsId).toBe("string");
expect.soft(typeof data.transferable).toBe("string");
expect.soft(typeof data.owner).toBe("string");
expect.soft(typeof data.mintedAt).toBe("string");
expect.soft(typeof data.expiresAt).toBe("string");
expect.soft(typeof data.burntAt).toBe("string");
expect.soft(typeof data.blockNumber).toBe("string");
expect.soft(typeof data.blockTime).toBe("string");
expect.soft(data.id).toBeTruthy();
expect.soft(data.licensorIpId).toBeTruthy();
expect.soft(data.licenseTemplate).toBeTruthy();
expect.soft(data.licenseTermsId).toBeTruthy();
expect.soft(data.transferable).toBeTruthy();
expect.soft(data.owner).toBeTruthy();
expect.soft(data.mintedAt).toBeTruthy();
expect.soft(data.expiresAt).toBeTruthy();
expect.soft(data.burntAt).toBeTruthy();
expect.soft(data.blockNumber).toBeTruthy();
expect.soft(data.blockTime).toBeTruthy();
});

test("query with non-exist id param", async ({ request }) => {
const response = await request.get(endpoint + "/00");
expect(response.status()).toBe(404);
});

test("query with no param", async ({ request }) => {
Expand Down
Loading