-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNftCollection.spec.ts
More file actions
64 lines (55 loc) · 2.5 KB
/
NftCollection.spec.ts
File metadata and controls
64 lines (55 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Blockchain, SandboxContract, TreasuryContract } from '@ton/sandbox';
import { Address, Cell, toNano } from '@ton/core';
import { NftCollection } from '../wrappers/NftCollection';
import { buildCollectionContentCell, setItemContentCell } from '../scripts/nftContent/onChain';
import '@ton/test-utils';
import { compile } from '@ton/blueprint';
describe('NftCollection', () => {
let collectionCode: Cell;
let item: Cell;
let collectionContent: Cell;
beforeAll(async () => {
collectionCode = await compile('NftCollection');
item = await compile('NftItem');
});
let blockchain: Blockchain;
let nftCollection: SandboxContract<NftCollection>;
let collectionOwner: SandboxContract<TreasuryContract>;
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: collectionContent,
nftItemCode: item,
royaltyParams: {
royaltyFactor: Math.floor(Math.random() * 500),
royaltyBase: 1000,
royaltyAddress: collectionOwner.getSender().address as Address
}
},collectionCode));
const deployer = await blockchain.treasury('deployer');
const deployResult = await nftCollection.sendDeploy(deployer.getSender(), toNano('0.05'));
expect(deployResult.transactions).toHaveTransaction({
from: deployer.address,
to: nftCollection.address,
deploy: true,
success: true,
});
});
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);
// check owner address
expect(collection_data.ownerAddress.toString()).toBe(collectionOwner.address.toString());
});
});