1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';20import {default as usingApi} from './substrate/substrate-api';21import {createCollectionExpectSuccess,22 destroyCollectionExpectSuccess,23 destroyCollectionExpectFailure,24 setCollectionLimitsExpectSuccess,25 addCollectionAdminExpectSuccess,26 getCreatedCollectionCount,27 createItemExpectSuccess,28 requirePallets,29 Pallets,30} from './util/helpers';3132chai.use(chaiAsPromised);3334describe('integration test: ext. destroyCollection():', () => {35 it('NFT collection can be destroyed', async () => {36 const collectionId = await createCollectionExpectSuccess();37 await destroyCollectionExpectSuccess(collectionId);38 });39 it('Fungible collection can be destroyed', async () => {40 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});41 await destroyCollectionExpectSuccess(collectionId);42 });43 it('ReFungible collection can be destroyed', async function() {44 await requirePallets(this, [Pallets.ReFungible]);4546 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});47 await destroyCollectionExpectSuccess(collectionId);48 });49});5051describe('(!negative test!) integration test: ext. destroyCollection():', () => {52 let alice: IKeyringPair;53 let bob: IKeyringPair;5455 before(async () => {56 await usingApi(async (api, privateKeyWrapper) => {57 alice = privateKeyWrapper('//Alice');58 bob = privateKeyWrapper('//Bob');59 });60 });6162 it('(!negative test!) Destroy a collection that never existed', async () => {63 await usingApi(async (api) => {64 65 const collectionId = await getCreatedCollectionCount(api) + 1;66 await destroyCollectionExpectFailure(collectionId);67 });68 });69 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {70 const collectionId = await createCollectionExpectSuccess();71 await destroyCollectionExpectSuccess(collectionId);72 await destroyCollectionExpectFailure(collectionId);73 });74 it('(!negative test!) Destroy a collection using non-owner account', async () => {75 const collectionId = await createCollectionExpectSuccess();76 await destroyCollectionExpectFailure(collectionId, '//Bob');77 await destroyCollectionExpectSuccess(collectionId, '//Alice');78 });79 it('(!negative test!) Destroy a collection using collection admin account', async () => {80 const collectionId = await createCollectionExpectSuccess();81 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);82 await destroyCollectionExpectFailure(collectionId, '//Bob');83 });84 it('fails when OwnerCanDestroy == false', async () => {85 const collectionId = await createCollectionExpectSuccess();86 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanDestroy: false});8788 await destroyCollectionExpectFailure(collectionId, '//Alice');89 });90 it('fails when a collection still has a token', async () => {91 const collectionId = await createCollectionExpectSuccess();92 await createItemExpectSuccess(alice, collectionId, 'NFT');9394 await destroyCollectionExpectFailure(collectionId, '//Alice');95 });96});