1234567891011121314151617import type {IKeyringPair} from '@polkadot/types/types';18import {itSub, expect, usingPlaygrounds, Pallets} from './util/index.js';1920describe('integration test: ext. destroyCollection():', () => {21 let alice: IKeyringPair;2223 before(async () => {24 await usingPlaygrounds(async (helper, privateKey) => {25 const donor = await privateKey({url: import.meta.url});26 [alice] = await helper.arrange.createAccounts([100n], donor);27 });28 });2930 itSub('NFT collection can be destroyed', async ({helper}) => {31 const collection = await helper.nft.mintCollection(alice, {32 name: 'test',33 description: 'test',34 tokenPrefix: 'test',35 });36 await collection.burn(alice);37 expect(await collection.getData()).to.be.null;38 });39 itSub('Fungible collection can be destroyed', async ({helper}) => {40 const collection = await helper.ft.mintCollection(alice, {41 name: 'test',42 description: 'test',43 tokenPrefix: 'test',44 }, 0);45 await collection.burn(alice);46 expect(await collection.getData()).to.be.null;47 });48 itSub.ifWithPallets('ReFungible collection can be destroyed', [Pallets.ReFungible], async ({helper}) => {49 const collection = await helper.rft.mintCollection(alice, {50 name: 'test',51 description: 'test',52 tokenPrefix: 'test',53 });54 await collection.burn(alice);55 expect(await collection.getData()).to.be.null;56 });57});5859describe('(!negative test!) integration test: ext. destroyCollection():', () => {60 let alice: IKeyringPair;61 let bob: IKeyringPair;6263 before(async () => {64 await usingPlaygrounds(async (helper, privateKey) => {65 const donor = await privateKey({url: import.meta.url});66 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);67 });68 });6970 itSub('(!negative test!) Destroy a collection that never existed', async ({helper}) => {71 const collectionId = 1_000_000;72 await expect(helper.collection.burn(alice, collectionId)).to.be.rejectedWith(/common\.CollectionNotFound/);73 });74 itSub('(!negative test!) Destroy a collection that has already been destroyed', async ({helper}) => {75 const collection = await helper.nft.mintCollection(alice, {76 name: 'test',77 description: 'test',78 tokenPrefix: 'test',79 });80 await collection.burn(alice);81 await expect(collection.burn(alice)).to.be.rejectedWith(/common\.CollectionNotFound/);82 });83 itSub('(!negative test!) Destroy a collection using non-owner account', async ({helper}) => {84 const collection = await helper.nft.mintCollection(alice, {85 name: 'test',86 description: 'test',87 tokenPrefix: 'test',88 });89 await expect(collection.burn(bob)).to.be.rejectedWith(/common\.NoPermission/);90 });91 itSub('(!negative test!) Destroy a collection using collection admin account', async ({helper}) => {92 const collection = await helper.nft.mintCollection(alice, {93 name: 'test',94 description: 'test',95 tokenPrefix: 'test',96 });97 await collection.addAdmin(alice, {Substrate: bob.address});98 await expect(collection.burn(bob)).to.be.rejectedWith(/common\.NoPermission/);99 });100 itSub('fails when OwnerCanDestroy == false', async ({helper}) => {101 const collection = await helper.nft.mintCollection(alice, {102 name: 'test',103 description: 'test',104 tokenPrefix: 'test',105 limits: {106 ownerCanDestroy: false,107 },108 });109 await expect(collection.burn(alice)).to.be.rejectedWith(/common\.NoPermission/);110 });111 itSub('fails when a collection still has a token', async ({helper}) => {112 const collection = await helper.nft.mintCollection(alice, {113 name: 'test',114 description: 'test',115 tokenPrefix: 'test',116 });117 await collection.mintToken(alice, {Substrate: alice.address});118 await expect(collection.burn(alice)).to.be.rejectedWith(/common\.CantDestroyNotEmptyCollection/);119 });120});