aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/test/assert_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-utils/test/assert_test.ts')
-rw-r--r--packages/order-utils/test/assert_test.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/order-utils/test/assert_test.ts b/packages/order-utils/test/assert_test.ts
new file mode 100644
index 000000000..dfd19bf86
--- /dev/null
+++ b/packages/order-utils/test/assert_test.ts
@@ -0,0 +1,35 @@
+import { web3Factory } from '@0xproject/dev-utils';
+import * as chai from 'chai';
+import 'mocha';
+
+import { assert } from '../src/assert';
+
+import { chaiSetup } from './utils/chai_setup';
+import { web3Wrapper } from './utils/web3_wrapper';
+
+chaiSetup.configure();
+const expect = chai.expect;
+
+describe('Assertion library', () => {
+ describe('#isSenderAddressHexAsync', () => {
+ it('throws when address is invalid', async () => {
+ const address = '0xdeadbeef';
+ const varName = 'address';
+ return expect(assert.isSenderAddressAsync(varName, address, 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 = 'address';
+ return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, web3Wrapper)).to.be.rejectedWith(
+ `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
+ );
+ });
+ it("doesn't throw if address is available", async () => {
+ const availableAddress = (await web3Wrapper.getAvailableAddressesAsync())[0];
+ const varName = 'address';
+ return expect(assert.isSenderAddressAsync(varName, availableAddress, web3Wrapper)).to.become(undefined);
+ });
+ });
+});