1import { assert } from 'chai';
2import privateKey from './substrate/privateKey';
3import usingApi from './substrate/substrate-api';
4import waitNewBlocks from './substrate/wait-new-blocks';
5
6describe('integration test: ext. createCollection():', () => {
7 it('Create new NFT collection', async () => {
8 await usingApi(async (api) => {
9 const alicePrivateKey = privateKey('//Alice');
10 const AcollectionCount = await api.query.nft.collectionCount();
11 await api.tx.nft
12 .createCollection('1', '1', '1', 'NFT')
13 .signAndSend(alicePrivateKey);
14 await waitNewBlocks(api);
15 const BcollectionCount = await api.query.nft.collectionCount();
16 if (BcollectionCount === AcollectionCount) {assert.fail('Error: NFT collection NOT created.'); }
17 });
18 });
19 it('Create new Fungible collection', async () => {
20 await usingApi(async (api) => {
21 const alicePrivateKey = privateKey('//Alice');
22 const AcollectionCount = await api.query.nft.collectionCount();
23 await api.tx.nft
24 .createCollection('1', '1', '1', 'Fungible')
25 .signAndSend(alicePrivateKey);
26 await waitNewBlocks(api);
27 const BcollectionCount = await api.query.nft.collectionCount();
28 if (BcollectionCount === AcollectionCount) {assert.fail('Error: Fungible collection NOT created.'); } });
29 });
30 it('Create new ReFungible collection', async () => {
31 await usingApi(async (api) => {
32 const alicePrivateKey = privateKey('//Alice');
33 const AcollectionCount = await api.query.nft.collectionCount();
34 await api.tx.nft
35 .createCollection('1', '1', '1', 'ReFungible')
36 .signAndSend(alicePrivateKey);
37 await waitNewBlocks(api);
38 const BcollectionCount = await api.query.nft.collectionCount();
39 if (BcollectionCount === AcollectionCount) {assert.fail('Error: ReFungible collection NOT created.'); } });
40 });
41});
42
43describe('(!negative test!) integration test: ext. createCollection():', () => {
44 it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
45 await usingApi(async (api) => {
46 const alicePrivateKey = privateKey('//Alice');
47 const AcollectionCount = await api.query.nft.collectionCount();
48 await api.tx.nft
49 .createCollection('1', '1', '1', 'BadMode')
50 .signAndSend(alicePrivateKey);
51 await waitNewBlocks(api);
52 const BcollectionCount = await api.query.nft.collectionCount();
53 if (BcollectionCount > AcollectionCount) {assert.fail('Error: Incorrect collection created.'); }
54 });
55 });
56 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {
57 await usingApi(async (api) => {
58 const alicePrivateKey = privateKey('//Alice');
59 const AcollectionCount = await api.query.nft.collectionCount();
60 await api.tx.nft
61 .createCollection('1', '1', '0x999', 'NFT')
62 .signAndSend(alicePrivateKey);
63 await waitNewBlocks(api);
64 const BcollectionCount = await api.query.nft.collectionCount();
65 if (BcollectionCount > AcollectionCount) {assert.fail('Incorrect data (token_prefix) created.'); }
66 });
67 });
68 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
69 await usingApi(async (api) => {
70 const alicePrivateKey = privateKey('//Alice');
71 const AcollectionCount = await api.query.nft.collectionCount();
72 await api.tx.nft
73 .createCollection('BadName', '1', '1', 'NFT')
74 .signAndSend(alicePrivateKey);
75 await waitNewBlocks(api);
76 const BcollectionCount = await api.query.nft.collectionCount();
77 if (BcollectionCount > AcollectionCount) {assert.fail('Incorrect data (collection_name) created.'); } });
78 });
79 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {
80 await usingApi(async (api) => {
81 const alicePrivateKey = privateKey('//Alice');
82 const AcollectionCount = await api.query.nft.collectionCount();
83 await api.tx.nft
84 .createCollection('1', 'BadDesk', '1', 'NFT')
85 .signAndSend(alicePrivateKey);
86 await waitNewBlocks(api);
87 const BcollectionCount = await api.query.nft.collectionCount();
88 if (BcollectionCount > AcollectionCount) {assert.fail('Incorrect data (collection_desc) created.'); } });
89 });
90});