git.delta.rocks / unique-network / refs/commits / 68096799e125

difftreelog

source

tests/src/createMultipleItems.test.ts3.5 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 { assert } from 'chai';7import { alicesPublicKey } from './accounts';8import privateKey from './substrate/privateKey';9import usingApi from './substrate/substrate-api';10import waitNewBlocks from './substrate/wait-new-blocks';1112const idCollection = 12;1314describe.skip('integration test: ext. createMultipleItems():', () => {15  it('Create two NFT tokens in active NFT collection', async () => {16    await usingApi(async (api) => {17      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);18      console.log(`itemListIndex count (before): ${AitemListIndex}`);19      const args = ['NFT', 'NFT'];20      const alicePrivateKey = privateKey('//Alice');21      const createMultipleItems = await api.tx.nft22      .createMultipleItems(idCollection, alicesPublicKey, args)23      .signAndSend(alicePrivateKey);24      // tslint:disable-next-line: no-unused-expression25      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');26      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);27      await waitNewBlocks(api);28      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);29      console.log(`itemListIndex count (after): ${BitemListIndex}`);30      if (BitemListIndex === AitemListIndex) { assert.fail('Corret token not added in collection!'); }31    });32  });33  it('(!negative test!) Create two Fungible tokens in active NFT collection', async () => {34    await usingApi(async (api) => {35      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);36      console.log(`itemListIndex count (before): ${AitemListIndex}`);37      const args = ['Fungible', 'Fungible'];38      const alicePrivateKey = privateKey('//Alice');39      const createMultipleItems = await api.tx.nft40      .createMultipleItems(idCollection, alicesPublicKey, args)41      .signAndSend(alicePrivateKey);42      // tslint:disable-next-line: no-unused-expression43      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');44      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);45      await waitNewBlocks(api);46      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);47      console.log(`itemListIndex count (after): ${BitemListIndex}`);48      if (BitemListIndex > AitemListIndex) { assert.fail('Incorrect token added in collection!'); }49    });50  });51  it('(!negative test!) Create two ReFungible tokens in active NFT collection', async () => {52    await usingApi(async (api) => {53      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);54      console.log(`itemListIndex count (before): ${AitemListIndex}`);55      const args = ['ReFungible', 'ReFungible'];56      const alicePrivateKey = privateKey('//Alice');57      const createMultipleItems = await api.tx.nft58      .createMultipleItems(idCollection, alicesPublicKey, args)59      .signAndSend(alicePrivateKey);60      // tslint:disable-next-line: no-unused-expression61      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');62      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);63      await waitNewBlocks(api);64      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);65      console.log(`itemListIndex count (after): ${BitemListIndex}`);66      if (BitemListIndex > AitemListIndex) { assert.fail('Incorrect token added in collection!'); }67    });68  });69});