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

difftreelog

source

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