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

difftreelog

source

tests/src/createCollection.test.ts2.8 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi } from './substrate/substrate-api';9import { createCollectionExpectFailure, createCollectionExpectSuccess } from './util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;1314describe('integration test: ext. createCollection():', () => {15  it('Create new NFT collection', async () => {16    await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: '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: {type: 'Fungible', decimalPoints: 0}});29  });30  it('Create new ReFungible collection', async () => {31    await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});32  });33});3435describe('(!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.createdCollectionCount()).toString(), 10);3940      const badTransaction = async () => {41        await createCollectionExpectSuccess({mode: {type: 'Invalid'}});42      };43      // tslint:disable-next-line:no-unused-expression44      expect(badTransaction()).to.be.rejected;4546      const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);47      expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');48    });49  });50  it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {51    await createCollectionExpectFailure({ name: 'A'.repeat(65), mode: {type: 'NFT'}});52  });53  it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {54    await createCollectionExpectFailure({ description: 'A'.repeat(257), mode: { type: 'NFT' }});55  });56  it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {57    await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});58  });59});