git.delta.rocks / unique-network / refs/commits / f4c09d673ad5

difftreelog

source

tests/src/createCollection.test.ts3.2 KiBsourcehistory
1import chai from 'chai';
2import chaiAsPromised from 'chai-as-promised';
3import { default as usingApi } from "./substrate/substrate-api";
4import { createCollectionExpectSuccess, createCollectionExpectFailure } from "./util/helpers";
5
6chai.use(chaiAsPromised);
7const expect = chai.expect;
8
9describe('integration test: ext. createCollection():', () => {
10  it('Create new NFT collection', async () => {
11    await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
12  });
13  it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {
14    await createCollectionExpectSuccess(
15      'ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCD',
16      '1', '1', 'NFT');
17  });
18  it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {
19    await createCollectionExpectSuccess(
20      'A', 
21      'ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJabcdef',
22      '1', 'NFT');
23  });
24  it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {
25    await createCollectionExpectSuccess(
26      '1', 
27      '1',
28      'ABCDEFGHIJABCDEF', 'NFT');
29  });
30  it('Create new Fungible collection', async () => {
31    await createCollectionExpectSuccess('1', '1', '1', 'Fungible');
32  });
33  it('Create new ReFungible collection', async () => {
34    await createCollectionExpectSuccess('1', '1', '1', 'ReFungible');
35  });
36});
37
38describe('(!negative test!) integration test: ext. createCollection():', () => {
39  it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
40    await usingApi(async (api) => {
41      const AcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
42
43      const badTransaction = async function () { 
44        await createCollectionExpectSuccess('1', '1', '1', 'BadMode');
45      };
46      expect(badTransaction()).to.be.rejected;
47
48      const BcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
49      expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');
50    });
51  });
52  it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
53    await createCollectionExpectFailure(
54      'ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDE', 
55      '1', '1', 'NFT');
56  });
57  it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {
58    await createCollectionExpectFailure('1',
59      'ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJabcdefg',
60      '1', 'NFT');
61  });
62  it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {
63    await createCollectionExpectFailure('1', '1', 
64    'ABCDEFGHIJABCDEFG',
65    'NFT');
66  });
67});