diff options
author | Fabio Berger <me@fabioberger.com> | 2017-08-17 06:44:39 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-08-17 06:44:39 +0800 |
commit | 20045a438ac60e319f23df9a199d81cfe655049b (patch) | |
tree | 4d5124be8bfe269a23c54eff516184ee005b6510 /test | |
parent | 2e668a771a5533182cfe010f022ab4c1f9afc1ba (diff) | |
download | dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar.gz dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar.bz2 dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar.lz dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar.xz dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.tar.zst dexon-sol-tools-20045a438ac60e319f23df9a199d81cfe655049b.zip |
remove unnecessary assertion and add regression test
Diffstat (limited to 'test')
-rw-r--r-- | test/token_wrapper_test.ts | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index d157efec4..45d5caa5b 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -176,7 +176,6 @@ describe('TokenWrapper', () => { before(async () => { const hasAddresses = false; const web3WithoutAccounts = web3Factory.create(hasAddresses); - web3WithoutAccounts.eth.getAccounts(console.log); zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider); }); it('should return balance even when called with Web3 provider instance without addresses', async () => { @@ -208,25 +207,49 @@ describe('TokenWrapper', () => { }); }); describe('#getAllowanceAsync', () => { - it('should get the proxy allowance', async () => { - const token = tokens[0]; - const ownerAddress = coinbase; - const spenderAddress = addressWithoutFunds; + describe('With web3 provider with accounts', () => { + it('should get the proxy allowance', async () => { + const token = tokens[0]; + const ownerAddress = coinbase; + const spenderAddress = addressWithoutFunds; - const amountInBaseUnits = new BigNumber(50); - await zeroEx.token.setAllowanceAsync(token.address, ownerAddress, spenderAddress, amountInBaseUnits); + const amountInBaseUnits = new BigNumber(50); + await zeroEx.token.setAllowanceAsync(token.address, ownerAddress, spenderAddress, amountInBaseUnits); - const allowance = await zeroEx.token.getAllowanceAsync(token.address, ownerAddress, spenderAddress); - const expectedAllowance = amountInBaseUnits; - return expect(allowance).to.be.bignumber.equal(expectedAllowance); + const allowance = await zeroEx.token.getAllowanceAsync(token.address, ownerAddress, spenderAddress); + const expectedAllowance = amountInBaseUnits; + return expect(allowance).to.be.bignumber.equal(expectedAllowance); + }); + it('should return 0 if no allowance set yet', async () => { + const token = tokens[0]; + const ownerAddress = coinbase; + const spenderAddress = addressWithoutFunds; + const allowance = await zeroEx.token.getAllowanceAsync(token.address, ownerAddress, spenderAddress); + const expectedAllowance = new BigNumber(0); + return expect(allowance).to.be.bignumber.equal(expectedAllowance); + }); }); - it('should return 0 if no allowance set yet', async () => { - const token = tokens[0]; - const ownerAddress = coinbase; - const spenderAddress = addressWithoutFunds; - const allowance = await zeroEx.token.getAllowanceAsync(token.address, ownerAddress, spenderAddress); - const expectedAllowance = new BigNumber(0); - return expect(allowance).to.be.bignumber.equal(expectedAllowance); + describe('With web3 provider without accounts', () => { + let zeroExWithoutAccounts: ZeroEx; + before(async () => { + const hasAddresses = false; + const web3WithoutAccounts = web3Factory.create(hasAddresses); + zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider); + }); + it('should get the proxy allowance', async () => { + const token = tokens[0]; + const ownerAddress = coinbase; + const spenderAddress = addressWithoutFunds; + + const amountInBaseUnits = new BigNumber(50); + await zeroEx.token.setAllowanceAsync(token.address, ownerAddress, spenderAddress, amountInBaseUnits); + + const allowance = await zeroExWithoutAccounts.token.getAllowanceAsync( + token.address, ownerAddress, spenderAddress, + ); + const expectedAllowance = amountInBaseUnits; + return expect(allowance).to.be.bignumber.equal(expectedAllowance); + }); }); }); describe('#getProxyAllowanceAsync', () => { |