diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-06 17:08:48 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-06 17:08:48 +0800 |
commit | d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d (patch) | |
tree | 66a00e18ae9aba95aeb4d8fbc5f91b6bccac875f /test | |
parent | fc912aff68479d099f2fc1a0671226503ac8e03c (diff) | |
download | dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar.gz dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar.bz2 dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar.lz dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar.xz dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.tar.zst dexon-sol-tools-d36fa171533e5c2dd5f511e5c213c27fd7cf3e4d.zip |
Add tests for isSenderAccountHexAsync
Diffstat (limited to 'test')
-rw-r--r-- | test/assert_test.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/assert_test.ts b/test/assert_test.ts new file mode 100644 index 000000000..2100611e9 --- /dev/null +++ b/test/assert_test.ts @@ -0,0 +1,33 @@ +import * as chai from 'chai'; +import 'mocha'; +import {ZeroEx} from '../src/0x.js'; +import {assert} from '../src/utils/assert'; +import {web3Factory} from './utils/web3_factory'; + +const expect = chai.expect; + +describe('Assertion library', () => { + const web3 = web3Factory.create(); + const zeroEx = new ZeroEx(web3); + describe('#isSenderAccountHexAsync', () => { + it('throws when address is invalid', async () => { + const address = '0xdeadbeef'; + const varName = 'account'; + return expect(assert.isSenderAccountHexAsync(varName, address, (zeroEx as any).web3Wrapper)) + .to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`); + }); + it('throws when address is unavailable', async () => { + const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42'; + const varName = 'account'; + return expect(assert.isSenderAccountHexAsync(varName, validUnrelatedAddress, (zeroEx as any).web3Wrapper)) + .to.be.rejectedWith(`Specified sender account ${validUnrelatedAddress} \ + isn't available through the supplied web3 instance`); + }); + it('doesn\'t throw if account is available', async () => { + const availableAccount = (await zeroEx.getAvailableAccountsAsync())[0]; + const varName = 'account'; + return expect(assert.isSenderAccountHexAsync(varName, availableAccount, (zeroEx as any).web3Wrapper)) + .to.become(undefined); + }); + }); +}); |