From 4b68421a192ff912cdf685caebd8be3de7bf06f1 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 19 Feb 2021 21:20:03 +0000 Subject: [PATCH] tests: destroyCollection respects OwnerCanDestroy --- --- a/tests/src/destroyCollection.test.ts +++ b/tests/src/destroyCollection.test.ts @@ -3,10 +3,12 @@ // file 'LICENSE', which is part of this source code package. // +import { IKeyringPair } from '@polkadot/types/types'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; +import privateKey from './substrate/privateKey'; import { default as usingApi } from "./substrate/substrate-api"; -import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers"; +import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure, setCollectionLimitsExpectSuccess } from "./util/helpers"; chai.use(chaiAsPromised); @@ -26,6 +28,14 @@ }); describe('(!negative test!) integration test: ext. destroyCollection():', () => { + let alice: IKeyringPair; + + before(async () => { + await usingApi(async (api) => { + alice = privateKey('//Alice'); + }); + }); + it('(!negative test!) Destroy a collection that never existed', async () => { await usingApi(async (api) => { // Find the collection that never existed @@ -43,4 +53,10 @@ await destroyCollectionExpectFailure(collectionId, '//Bob'); await destroyCollectionExpectSuccess(collectionId, '//Alice'); }); + it('fails when OwnerCanDestroy == false', async () => { + const collectionId = await createCollectionExpectSuccess(); + await setCollectionLimitsExpectSuccess(alice, collectionId, { OwnerCanDestroy: false }); + + await destroyCollectionExpectFailure(collectionId, '//Alice'); + }); }); -- gitstuff