git.delta.rocks / unique-network / refs/commits / 280307ce9910

difftreelog

source

tests/src/destroyCollection.test.ts2.6 KiBsourcehistory
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});