difftreelog
Add delete property negative tests
in: master
1 file changed
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth240 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {240 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {241 caller = await helper.eth.createAccountWithBalance(donor);241 caller = await helper.eth.createAccountWithBalance(donor);242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);243 // Caller an owner and not an admin, so he cannot set properties:243 // Caller not an owner and not an admin, so he cannot set properties:244 // FIXME: Can setProperties as non owner and non admin244 // FIXME: Can setProperties as non owner and non admin245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');246 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;246 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;264 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;264 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;265265266 // Props have not changed:266 // Props have not changed:267 const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));267 const actualProps = await collectionEvm.methods.properties(token.tokenId, ['testKey2']).call();268 const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();268 expect(actualProps).to.deep.eq(tokenProps269 expect(actualProps).to.deep.eq(expectedProps);269 .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); 270 }));271 }));270 }));272271272 [273 {method: 'deleteProperty', methodParams: ['testKey_2']}, // FIXME: the method is gone?274 {method: 'deleteProperties', methodParams: [['testKey_2']]},275 ].map(testCase => 273 itEth('Cannot delete properties of non-owned collection', async () => {276 itEth('Cannot delete properties of non-owned collection', async ({helper}) => {274277 caller = await helper.eth.createAccountWithBalance(donor);278 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);279 // Caller not an owner and not an admin, so he cannot set properties:280 // FIXME: non owner and non admin can deleteProperties281 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});282 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');283 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;284285 // Props have not changed:286 const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));287 const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();288 expect(actualProps).to.deep.eq(expectedProps);275 });289 }));276290277 itEth('Cannot delete non-existing properties', async () => {291 itEth('Cannot delete non-existing properties', async () => {278292