difftreelog
Combine transactions and expects
in: master
2 files changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth56 const collection = await helper.collection.getData(collectionId);56 const collection = await helper.collection.getData(collectionId);57 expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));57 expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));585859 const changeAdminTxBob = () => helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address});59 await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);60 const changeAdminTxCharlie = () => helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address});60 await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.NoPermission/);61 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);62 await expect(changeAdminTxBob()).to.be.rejectedWith(/common\.NoPermission/);636164 const adminListAfterAddAdmin = await helper.collection.getAdmins(collectionId);62 const adminListAfterAddAdmin = await helper.collection.getAdmins(collectionId);65 expect(adminListAfterAddAdmin).to.be.not.deep.contains({Substrate: charlie.address});63 expect(adminListAfterAddAdmin).to.be.not.deep.contains({Substrate: charlie.address});75 const adminListAfterAddAdmin = await collection.getAdmins();73 const adminListAfterAddAdmin = await collection.getAdmins();76 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});74 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});777578 const changeAdminTxCharlie = () => collection.addAdmin(bob, {Substrate: charlie.address});76 await expect(collection.addAdmin(bob, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);79 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);807781 const adminListAfterAddNewAdmin = await collection.getAdmins();78 const adminListAfterAddNewAdmin = await collection.getAdmins();82 expect(adminListAfterAddNewAdmin).to.be.deep.contains({Substrate: bob.address});79 expect(adminListAfterAddNewAdmin).to.be.deep.contains({Substrate: bob.address});87 const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);84 const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);88 const collectionId = (1 << 32) - 1;85 const collectionId = (1 << 32) - 1;898690 const addAdminTx = () => helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});87 await expect(helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);91 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);928893 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)89 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)94 await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});90 await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});99 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});95 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});10096101 await collection.burn(alice);97 await collection.burn(alice);102 const addAdminTx = () => collection.addAdmin(alice, {Substrate: bob.address});98 await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);103 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);10499105 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)100 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)106 await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});101 await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});119 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});114 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});120 }115 }121116122 const addExtraAdminTx = () => collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address});117 await expect(collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address})).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);123 await expect(addExtraAdminTx()).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);124 });118 });125});119});126120tests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth--- a/tests/src/adminTransferAndBurn.test.ts
+++ b/tests/src/adminTransferAndBurn.test.ts
@@ -36,8 +36,7 @@
expect(limits.ownerCanTransfer).to.be.true;
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const transferResult = () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});
- await expect(transferResult()).to.be.rejected;
+ await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address})).to.be.rejected;
await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
@@ -52,9 +51,8 @@
expect(limits.ownerCanTransfer).to.be.true;
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const burnTxFailed = () => helper.nft.burnToken(alice, collectionId, tokenId);
- await expect(burnTxFailed()).to.be.rejected;
+ await expect(helper.nft.burnToken(alice, collectionId, tokenId)).to.be.rejected;
await helper.nft.burnToken(bob, collectionId, tokenId);
const token = await helper.nft.getToken(collectionId, tokenId);