--- 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; }); }