difftreelog
tests: destroyCollection respects OwnerCanDestroy
in: master
1 file changed
tests/src/destroyCollection.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi } from "./substrate/substrate-api";9import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";1011chai.use(chaiAsPromised);1213describe('integration test: ext. destroyCollection():', () => {14 it('NFT collection can be destroyed', async () => {15 const collectionId = await createCollectionExpectSuccess();16 await destroyCollectionExpectSuccess(collectionId);17 });18 it('Fungible collection can be destroyed', async () => {19 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});20 await destroyCollectionExpectSuccess(collectionId);21 });22 it('ReFungible collection can be destroyed', async () => {23 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});24 await destroyCollectionExpectSuccess(collectionId);25 });26});2728describe('(!negative test!) integration test: ext. destroyCollection():', () => {29 it('(!negative test!) Destroy a collection that never existed', async () => {30 await usingApi(async (api) => {31 // Find the collection that never existed32 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;33 await destroyCollectionExpectFailure(collectionId);34 });35 });36 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {37 const collectionId = await createCollectionExpectSuccess();38 await destroyCollectionExpectSuccess(collectionId);39 await destroyCollectionExpectFailure(collectionId);40 });41 it('(!negative test!) Destroy a collection using non-owner account', async () => {42 const collectionId = await createCollectionExpectSuccess();43 await destroyCollectionExpectFailure(collectionId, '//Bob');44 await destroyCollectionExpectSuccess(collectionId, '//Alice');45 });46});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { 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, destroyCollectionExpectSuccess, destroyCollectionExpectFailure, setCollectionLimitsExpectSuccess } from "./util/helpers";1213chai.use(chaiAsPromised);1415describe('integration test: ext. destroyCollection():', () => {16 it('NFT collection can be destroyed', async () => {17 const collectionId = await createCollectionExpectSuccess();18 await destroyCollectionExpectSuccess(collectionId);19 });20 it('Fungible collection can be destroyed', async () => {21 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});22 await destroyCollectionExpectSuccess(collectionId);23 });24 it('ReFungible collection can be destroyed', async () => {25 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});26 await destroyCollectionExpectSuccess(collectionId);27 });28});2930describe('(!negative test!) integration test: ext. destroyCollection():', () => {31 let alice: IKeyringPair;3233 before(async () => {34 await usingApi(async (api) => {35 alice = privateKey('//Alice');36 });37 });3839 it('(!negative test!) Destroy a collection that never existed', async () => {40 await usingApi(async (api) => {41 // Find the collection that never existed42 const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;43 await destroyCollectionExpectFailure(collectionId);44 });45 });46 it('(!negative test!) Destroy a collection that has already been destroyed', async () => {47 const collectionId = await createCollectionExpectSuccess();48 await destroyCollectionExpectSuccess(collectionId);49 await destroyCollectionExpectFailure(collectionId);50 });51 it('(!negative test!) Destroy a collection using non-owner account', async () => {52 const collectionId = await createCollectionExpectSuccess();53 await destroyCollectionExpectFailure(collectionId, '//Bob');54 await destroyCollectionExpectSuccess(collectionId, '//Alice');55 });56 it('fails when OwnerCanDestroy == false', async () => {57 const collectionId = await createCollectionExpectSuccess();58 await setCollectionLimitsExpectSuccess(alice, collectionId, { OwnerCanDestroy: false });5960 await destroyCollectionExpectFailure(collectionId, '//Alice');61 });62});