Just started with unit testing after creating my token, but the test cases are passing even if I add a number in the equals bracket.
In test one, if I change to expect(await instance.balanceOf(deployerAccount)).to.be.a.bignumber.equal(totalSupply+1);
then the test case fails, but not when using eventually
.
Doing the same as above for other test case, does not work, they simply fail even when correct.
What am I missing out?
contract("Token Test",async (accounts)=>{
const[deployerAccount, recepient, anotherAccount]=accounts;
it("one-all tokens should be in my account", async () => {
let instance = await Token.deployed();
let totalSupply =await instance.totalSupply();
expect(instance.balanceOf(deployerAccount)).to.eventually.be.a.bignumber.equal(totalSupply);
})
it("two-is possible to send token between accounts", async () => {
const sendTokens=1;
let instance= await Token.deployed();
let totalSupply = await instance.totalSupply()+1;
expect(instance.balanceOf(deployerAccount)).to.eventually.be.a.bignumber.equal(totalSupply);
expect(instance.transfer(recepient, sendTokens)).to.eventually.be.fulfilled;
expect(instance.balanceOf(deployerAccount)).to.eventually.be.a.bignumber.equal(totalSupply.sub(new BN(sendTokens)));
expect(instance.balanceOf(recepient)).to.eventually.be.a.bignumber.equal(new BN(sendTokens));
})
it("three-is not possible to send more tokens than available in total", async()=>{
let instance=await Token.deployed();
let balanceOfDeployer=await instance.balanceOf(deployerAccount);
expect(instance.transfer(recepient,new BN(balanceOfDeployer+1))).to.be.rejected;
expect(instance.balanceOf(deployerAccount)).to.be.bignumber.equal(balanceOfDeployer);
})
});
Did I make sense? please help!
eventually
myself, and not sure, but the documentation at chaijs.com/plugins/chai-as-promised usesshould
. Maybe try that?