123456import {IKeyringPair} from '@polkadot/types/types';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import {default as usingApi} from './substrate/substrate-api';11import {createCollectionExpectSuccess,12 destroyCollectionExpectSuccess,13 destroyCollectionExpectFailure,14 setCollectionLimitsExpectSuccess,15 addCollectionAdminExpectSuccess,16} from './util/helpers';1718chai.use(chaiAsPromised);1920describe('integration test: ext. destroyCollection():', () => {21 it('NFT collection can be destroyed', async () => {22 const collectionId = await createCollectionExpectSuccess();23 await destroyCollectionExpectSuccess(collectionId);24 });25 it('Fungible collection can be destroyed', async () => {26 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});27 await destroyCollectionExpectSuccess(collectionId);28 });29 it('ReFungible collection can be destroyed', async () => {30 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});31 await destroyCollectionExpectSuccess(collectionId);32 });33});3435describe('(!negative test!) integration test: ext. destroyCollection():', () => {36 let alice: IKeyringPair;37 let bob: IKeyringPair;3839 before(async () => {40 await usingApi(async () => {41 alice = privateKey('//Alice');42 bob = privateKey('//Bob');43 });44 });4546 it('(!negative test!) Destroy a collection that never existed', async () => {47 await usingApi(async (api) => {48 49 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;50 await destroyCollectionExpectFailure(collectionId);51 });52 });53 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {54 const collectionId = await createCollectionExpectSuccess();55 await destroyCollectionExpectSuccess(collectionId);56 await destroyCollectionExpectFailure(collectionId);57 });58 it('(!negative test!) Destroy a collection using non-owner account', async () => {59 const collectionId = await createCollectionExpectSuccess();60 await destroyCollectionExpectFailure(collectionId, '//Bob');61 await destroyCollectionExpectSuccess(collectionId, '//Alice');62 });63 it('(!negative test!) Destroy a collection using collection admin account', async () => {64 const collectionId = await createCollectionExpectSuccess();65 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);66 await destroyCollectionExpectFailure(collectionId, '//Bob');67 });68 it('fails when OwnerCanDestroy == false', async () => {69 const collectionId = await createCollectionExpectSuccess();70 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanDestroy: false});7172 await destroyCollectionExpectFailure(collectionId, '//Alice');73 });74});