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

difftreelog

source

tests/src/destroyCollection.test.ts2.1 KiBsourcehistory
1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";4import { createCollectionExpectSuccess, createCollectionExpectFailure, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";5import type { AccountId, EventRecord } from '@polkadot/types/interfaces';6import privateKey from './substrate/privateKey';78chai.use(chaiAsPromised);9const expect = chai.expect;1011describe('integration test: ext. destroyCollection():', () => {12  it('NFT collection can be destroyed', async () => {13    const collectionId = await createCollectionExpectSuccess();14    await destroyCollectionExpectSuccess(collectionId);15  });16  it('Fungible collection can be destroyed', async () => {17    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});18    await destroyCollectionExpectSuccess(collectionId);19  });20  it('ReFungible collection can be destroyed', async () => {21    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});22    await destroyCollectionExpectSuccess(collectionId);23  });24});2526describe('(!negative test!) integration test: ext. destroyCollection():', () => {27  it('(!negative test!) Destroy a collection that never existed', async () => {28    await usingApi(async (api) => {29      // Find the collection that never existed30      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;31      await destroyCollectionExpectFailure(collectionId);32    });33  });34  it('(!negative test!) Destroy a collection that has already been destroyed', async () => {35    const collectionId = await createCollectionExpectSuccess();36    await destroyCollectionExpectSuccess(collectionId);37    await destroyCollectionExpectFailure(collectionId);38  });39  it('(!negative test!) Destroy a collection using non-owner account', async () => {40    const collectionId = await createCollectionExpectSuccess();41    await destroyCollectionExpectFailure(collectionId, '//Bob');42    await destroyCollectionExpectSuccess(collectionId, '//Alice');43  });44});