difftreelog
Tests updated
in: master
2 files changed
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -15,6 +15,12 @@
enableWhiteListExpectSuccess,
setMintPermissionExpectSuccess,
destroyCollectionExpectSuccess,
+ setCollectionSponsorExpectFailure,
+ confirmSponsorshipExpectFailure,
+ removeCollectionSponsorExpectFailure,
+ enableWhiteListExpectFail,
+ setMintPermissionExpectFailure,
+ destroyCollectionExpectFailure,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -53,7 +59,7 @@
await submitTransactionAsync(alice, changeOwnerTx);
const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
- await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);
@@ -169,14 +175,14 @@
await submitTransactionAsync(alice, changeOwnerTx);
const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
- await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);
- await expect(setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Alice')).to.be.rejected;
- await expect(confirmSponsorshipExpectSuccess(collectionId, '//Alice')).to.be.rejected;
- await expect(removeCollectionSponsorExpectSuccess(collectionId, '//Alice')).to.be.rejected;
+ await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');
+ await confirmSponsorshipExpectFailure(collectionId, '//Alice');
+ await removeCollectionSponsorExpectFailure(collectionId, '//Alice');
const collectionLimits = {
AccountTokenOwnershipLimit: 1,
@@ -190,11 +196,11 @@
collectionId,
collectionLimits,
);
- await expect(submitTransactionAsync(alice, tx1)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, tx1)).to.be.rejected;
- await expect(enableWhiteListExpectSuccess(alice, collectionId)).to.be.rejected;
- await expect(setMintPermissionExpectSuccess(alice, collectionId, true)).to.be.rejected;
- await expect(destroyCollectionExpectSuccess(collectionId, '//Alice')).to.be.rejected;
+ await enableWhiteListExpectFail(alice, collectionId);
+ await setMintPermissionExpectFailure(alice, collectionId, true);
+ await destroyCollectionExpectFailure(collectionId, '//Alice');
});
});
});
tests/src/util/helpers.tsdiffbeforeafterboth1006 });1006 });1007}1007}10081009export async function setPublicAccessModeExpectFail(1010 sender: IKeyringPair, collectionId: number,1011 accessMode: 'Normal' | 'WhiteList',1012) {1013 await usingApi(async (api) => {10141015 // Run the transaction1016 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);1017 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1018 const result = getGenericResult(events);10191020 // What to expect1021 // tslint:disable-next-line:no-unused-expression1022 expect(result.success).to.be.false;1023 });1024}100810251009export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1026export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1010 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1027 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1011}1028}10291030export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {1031 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');1032}101210331013export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1034export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1014 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1035 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');