From 9f99a88f6be81988f67f290fe5ae9f4ad8d1a976 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Tue, 26 Jan 2021 08:42:59 +0000 Subject: [PATCH] tests: add setMintPermission helpers --- --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -606,11 +606,11 @@ }); } -export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) { +export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) { await usingApi(async (api) => { // Run the transaction - const tx = api.tx.nft.setMintPermission(collectionId, true); + const tx = api.tx.nft.setMintPermission(collectionId, enabled); const events = await submitTransactionAsync(sender, tx); const result = getGenericResult(events); @@ -618,8 +618,24 @@ const collection: any = (await api.query.nft.collection(collectionId)).toJSON(); // What to expect + // tslint:disable-next-line:no-unused-expression expect(result.success).to.be.true; - expect(collection.MintMode).to.be.equal(true); + expect(collection.MintMode).to.be.equal(enabled); + }); +} + +export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) { + await setMintPermissionExpectSuccess(sender, collectionId, true); +} + +export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) { + await usingApi(async (api) => { + // Run the transaction + const tx = api.tx.nft.setMintPermission(collectionId, enabled); + const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected; + const result = getCreateCollectionResult(events); + // tslint:disable-next-line:no-unused-expression + expect(result.success).to.be.false; }); } -- gitstuff