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

difftreelog

source

tests/src/check-event/transferEvent.test.ts1.6 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//56// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits7import { ApiPromise } from '@polkadot/api';8import { IKeyringPair } from '@polkadot/types/types';9import chai from 'chai';10import chaiAsPromised from 'chai-as-promised';11import privateKey from '../substrate/privateKey';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';13import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage } from '../util/helpers';1415chai.use(chaiAsPromised);16const expect = chai.expect;1718describe('Transfer event ', () => {19  let Alice: IKeyringPair;20  let Bob: IKeyringPair;21  const checkSection = 'Transfer';22  const checkTreasury = 'Deposit';23  const checkSystem = 'ExtrinsicSuccess';24  before(async () => {25    await usingApi(async () => {26      Alice = privateKey('//Alice');27      Bob = privateKey('//Bob');28    });29  });30  it('Check event from transfer(): ', async () => {31    await usingApi(async (api: ApiPromise) => {32      const collectionID = await createCollectionExpectSuccess();33      const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');34      const transfer = api.tx.nft.transfer(Bob.address, collectionID, itemID, 1);35      const events = await submitTransactionAsync(Alice, transfer);36      const msg = JSON.stringify(nftEventMessage(events));37      expect(msg).to.be.contain(checkSection);38      expect(msg).to.be.contain(checkTreasury);39      expect(msg).to.be.contain(checkSystem);40    });41  });42});4344