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

difftreelog

source

tests/src/createCollection.test.ts2.7 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, CollectionMode } 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({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});
17  });
18  it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {
19    await createCollectionExpectSuccess({name: 'A'.repeat(64)});
20  });
21  it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {
22    await createCollectionExpectSuccess({description: 'A'.repeat(256)});
23  });
24  it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {
25    await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});
26  });
27  it('Create new Fungible collection', async () => {
28    await createCollectionExpectSuccess({mode: 'Fungible'});
29  });
30  it('Create new ReFungible collection', async () => {
31    await createCollectionExpectSuccess({mode: 'ReFungible'});
32  });
33});
34
35describe('(!negative test!) integration test: ext. createCollection():', () => {
36  it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
37    await usingApi(async (api) => {
38      const AcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
39
40      const badTransaction = async function () { 
41        await createCollectionExpectSuccess({mode: 'BadMode' as CollectionMode});
42      };
43      expect(badTransaction()).to.be.rejected;
44
45      const BcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
46      expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');
47    });
48  });
49  it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
50    await createCollectionExpectFailure({name: 'A'.repeat(65)});
51  });
52  it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {
53    await createCollectionExpectFailure({description: 'A'.repeat(257)});
54  });
55  it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {
56    await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17)});
57  });
58});