Skip to content
Open
Changes from 1 commit
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
29 changes: 18 additions & 11 deletions tests/NftCollection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import '@ton/test-utils';
import { compile } from '@ton/blueprint';

describe('NftCollection', () => {
let code: Cell;
let collectionCode: Cell;
let item: Cell;
let collectionContent: Cell;

beforeAll(async () => {
code = await compile('NftCollection');
collectionCode = await compile('NftCollection');
item = await compile('NftItem');
});

Expand All @@ -21,22 +22,23 @@ describe('NftCollection', () => {
beforeEach(async () => {
blockchain = await Blockchain.create();
collectionOwner = await blockchain.treasury("ownerWallet");
collectionContent = buildCollectionContentCell({
name: "OnChain collection",
description: "Collection of items with onChain metadata",
image: "https://raw.githubusercontent.com/Cosmodude/Nexton/main/Nexton_Logo.jpg"
});

nftCollection = blockchain.openContract(NftCollection.createFromConfig({
ownerAddress: collectionOwner.address,
nextItemIndex: 0,
collectionContent: buildCollectionContentCell({
name: "OnChain collection",
description: "Collection of items with onChain metadata",
image: "https://raw.githubusercontent.com/Cosmodude/Nexton/main/Nexton_Logo.jpg"
}),
collectionContent: collectionContent,
nftItemCode: item,
royaltyParams: {
royaltyFactor: Math.floor(Math.random() * 500),
royaltyBase: 1000,
royaltyAddress: collectionOwner.getSender().address as Address
}
}, code));
},collectionCode));

const deployer = await blockchain.treasury('deployer');

Expand All @@ -50,8 +52,13 @@ describe('NftCollection', () => {
});
});

it('should deploy', async () => {
// the check is done inside beforeEach
// blockchain and nftCollection are ready to use
it('should get collection data after it\'s been deployed', async () => {
const collection_data = await nftCollection.getCollectionData();
// check next_item_index
expect(collection_data).toHaveProperty("nextItemId", BigInt(0));
// check collection content
expect(collection_data.collectionContent).toEqualCell(collectionContent);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to check all the content fields one by one (name, description and image).

You can refer to these tests

https://github.com/Cosmodude/Nexton/blob/main/tests/NexTon.spec.ts#L111C9-L111C15

// check owner address
expect(collection_data.ownerAddress.toString()).toBe(collectionOwner.address.toString());
});
});