git.delta.rocks / unique-network / refs/commits / 7781ab982a4b

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, uniqueEventMessage, normalizeAccountId} 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.unique.transfer(normalizeAccountId(bob.address), collectionID, itemID, 1);35      const events = await submitTransactionAsync(alice, transfer);36      const msg = JSON.stringify(uniqueEventMessage(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});