git.delta.rocks / unique-network / refs/commits / 0032fbbc5455

difftreelog

source

tests/src/createMultipleItems.test.ts3.4 KiBsourcehistory
1import { assert } from 'chai';2import { alicesPublicKey } from './accounts';3import privateKey from './substrate/privateKey';4import usingApi from './substrate/substrate-api';5import waitNewBlocks from './substrate/wait-new-blocks';67const idCollection = 12;89describe('integration test: ext. createMultipleItems():', () => {10  it('Create two NFT tokens in active NFT collection', async () => {11    await usingApi(async (api) => {12      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);13      console.log(`itemListIndex count (before): ${AitemListIndex}`);14      const args = ['NFT', 'NFT'];15      const alicePrivateKey = privateKey('//Alice');16      const createMultipleItems = await api.tx.nft17      .createMultipleItems(idCollection, alicesPublicKey, args)18      .signAndSend(alicePrivateKey);19      // tslint:disable-next-line: no-unused-expression20      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');21      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);22      await waitNewBlocks(api);23      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);24      console.log(`itemListIndex count (after): ${BitemListIndex}`);25      if (BitemListIndex === AitemListIndex) { assert.fail('Corret token not added in collection!'); }26    });27  });28  it('(!negative test!) Create two Fungible tokens in active NFT collection', async () => {29    await usingApi(async (api) => {30      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);31      console.log(`itemListIndex count (before): ${AitemListIndex}`);32      const args = ['Fungible', 'Fungible'];33      const alicePrivateKey = privateKey('//Alice');34      const createMultipleItems = await api.tx.nft35      .createMultipleItems(idCollection, alicesPublicKey, args)36      .signAndSend(alicePrivateKey);37      // tslint:disable-next-line: no-unused-expression38      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');39      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);40      await waitNewBlocks(api);41      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);42      console.log(`itemListIndex count (after): ${BitemListIndex}`);43      if (BitemListIndex > AitemListIndex) { assert.fail('Incorrect token added in collection!'); }44    });45  });46  it('(!negative test!) Create two ReFungible tokens in active NFT collection', async () => {47    await usingApi(async (api) => {48      const AitemListIndex = await api.query.nft.itemListIndex(idCollection);49      console.log(`itemListIndex count (before): ${AitemListIndex}`);50      const args = ['ReFungible', 'ReFungible'];51      const alicePrivateKey = privateKey('//Alice');52      const createMultipleItems = await api.tx.nft53      .createMultipleItems(idCollection, alicesPublicKey, args)54      .signAndSend(alicePrivateKey);55      // tslint:disable-next-line: no-unused-expression56      assert.exists(createMultipleItems, 'createMultipleItems is neither `null` or `undefined`');57      console.log(`Ext. createMultipleItems submitted with hash: ${createMultipleItems}`);58      await waitNewBlocks(api);59      const BitemListIndex = await api.query.nft.itemListIndex(idCollection);60      console.log(`itemListIndex count (after): ${BitemListIndex}`);61      if (BitemListIndex > AitemListIndex) { assert.fail('Incorrect token added in collection!'); }62    });63  });64});