1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import {default as usingApi} from './substrate/substrate-api';22import {createCollectionExpectSuccess,23 destroyCollectionExpectSuccess,24 destroyCollectionExpectFailure,25 setCollectionLimitsExpectSuccess,26 addCollectionAdminExpectSuccess,27 getCreatedCollectionCount,28 createItemExpectSuccess,29} from './util/helpers';3031chai.use(chaiAsPromised);3233describe('integration test: ext. destroyCollection():', () => {34 it('NFT collection can be destroyed', async () => {35 const collectionId = await createCollectionExpectSuccess();36 await destroyCollectionExpectSuccess(collectionId);37 });38 it('Fungible collection can be destroyed', async () => {39 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});40 await destroyCollectionExpectSuccess(collectionId);41 });42 it('ReFungible collection can be destroyed', async () => {43 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});44 await destroyCollectionExpectSuccess(collectionId);45 });46});4748describe('(!negative test!) integration test: ext. destroyCollection():', () => {49 let alice: IKeyringPair;50 let bob: IKeyringPair;5152 before(async () => {53 await usingApi(async () => {54 alice = privateKey('//Alice');55 bob = privateKey('//Bob');56 });57 });5859 it('(!negative test!) Destroy a collection that never existed', async () => {60 await usingApi(async (api) => {61 62 const collectionId = await getCreatedCollectionCount(api) + 1;63 await destroyCollectionExpectFailure(collectionId);64 });65 });66 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {67 const collectionId = await createCollectionExpectSuccess();68 await destroyCollectionExpectSuccess(collectionId);69 await destroyCollectionExpectFailure(collectionId);70 });71 it('(!negative test!) Destroy a collection using non-owner account', async () => {72 const collectionId = await createCollectionExpectSuccess();73 await destroyCollectionExpectFailure(collectionId, '//Bob');74 await destroyCollectionExpectSuccess(collectionId, '//Alice');75 });76 it('(!negative test!) Destroy a collection using collection admin account', async () => {77 const collectionId = await createCollectionExpectSuccess();78 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);79 await destroyCollectionExpectFailure(collectionId, '//Bob');80 });81 it('fails when OwnerCanDestroy == false', async () => {82 const collectionId = await createCollectionExpectSuccess();83 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanDestroy: false});8485 await destroyCollectionExpectFailure(collectionId, '//Alice');86 });87 it('fails when a collection still has a token', async () => {88 const collectionId = await createCollectionExpectSuccess();89 await createItemExpectSuccess(alice, collectionId, 'NFT');9091 await destroyCollectionExpectFailure(collectionId, '//Alice');92 });93});