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 getCreatedCollectionCount,17} from './util/helpers';1819chai.use(chaiAsPromised);2021describe('integration test: ext. destroyCollection():', () => {22 it('NFT collection can be destroyed', async () => {23 const collectionId = await createCollectionExpectSuccess();24 await destroyCollectionExpectSuccess(collectionId);25 });26 it('Fungible collection can be destroyed', async () => {27 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});28 await destroyCollectionExpectSuccess(collectionId);29 });30 it('ReFungible collection can be destroyed', async () => {31 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});32 await destroyCollectionExpectSuccess(collectionId);33 });34});3536describe('(!negative test!) integration test: ext. destroyCollection():', () => {37 let alice: IKeyringPair;38 let bob: IKeyringPair;3940 before(async () => {41 await usingApi(async () => {42 alice = privateKey('//Alice');43 bob = privateKey('//Bob');44 });45 });4647 it('(!negative test!) Destroy a collection that never existed', async () => {48 await usingApi(async (api) => {49 50 const collectionId = await getCreatedCollectionCount(api) + 1;51 await destroyCollectionExpectFailure(collectionId);52 });53 });54 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {55 const collectionId = await createCollectionExpectSuccess();56 await destroyCollectionExpectSuccess(collectionId);57 await destroyCollectionExpectFailure(collectionId);58 });59 it('(!negative test!) Destroy a collection using non-owner account', async () => {60 const collectionId = await createCollectionExpectSuccess();61 await destroyCollectionExpectFailure(collectionId, '//Bob');62 await destroyCollectionExpectSuccess(collectionId, '//Alice');63 });64 it('(!negative test!) Destroy a collection using collection admin account', async () => {65 const collectionId = await createCollectionExpectSuccess();66 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);67 await destroyCollectionExpectFailure(collectionId, '//Bob');68 });69 it('fails when OwnerCanDestroy == false', async () => {70 const collectionId = await createCollectionExpectSuccess();71 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanDestroy: false});7273 await destroyCollectionExpectFailure(collectionId, '//Alice');74 });75});