aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-11 05:31:48 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-13 09:06:13 +0800
commit61e7b735dcae37195e4b306cab3e4c50cd9c3ba5 (patch)
treec838c96ebbdf6e235a7e7a163a1cc6e955f0dbba
parent44c15fc1ef955a4e188708590eb45eebfea60f12 (diff)
downloaddexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar.gz
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar.bz2
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar.lz
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar.xz
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.tar.zst
dexon-sol-tools-61e7b735dcae37195e4b306cab3e4c50cd9c3ba5.zip
Adjust tests to new interface
-rw-r--r--test/order_state_watcher_test.ts25
1 files changed, 11 insertions, 14 deletions
diff --git a/test/order_state_watcher_test.ts b/test/order_state_watcher_test.ts
index 41f938584..880ef0fc3 100644
--- a/test/order_state_watcher_test.ts
+++ b/test/order_state_watcher_test.ts
@@ -15,6 +15,7 @@ import {
ZeroExConfig,
OrderState,
SignedOrder,
+ ZeroExError,
OrderStateValid,
OrderStateInvalid,
ExchangeContractErrs,
@@ -92,14 +93,10 @@ describe('OrderStateWatcher', () => {
afterEach(async () => {
zeroEx.orderStateWatcher.unsubscribe();
});
- it('should fail when trying to subscribe twice', (done: DoneCallback) => {
- zeroEx.orderStateWatcher.subscribe(_.noop);
- try {
- zeroEx.orderStateWatcher.subscribe(_.noop);
- done(new Error('Expected the second subscription to fail'));
- } catch (err) {
- done();
- }
+ it('should fail when trying to subscribe twice', async () => {
+ await zeroEx.orderStateWatcher.subscribeAsync(_.noop);
+ return expect(zeroEx.orderStateWatcher.subscribeAsync(_.noop))
+ .to.be.rejectedWith(ZeroExError.SubscriptionAlreadyPresent);
});
});
describe('tests with cleanup', async () => {
@@ -122,7 +119,7 @@ describe('OrderStateWatcher', () => {
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerAllowance);
done();
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0));
})().catch(done);
});
@@ -161,7 +158,7 @@ describe('OrderStateWatcher', () => {
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerBalance);
done();
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
const anyRecipient = taker;
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
await zeroEx.token.transferAsync(makerToken.address, maker, anyRecipient, makerBalance);
@@ -186,7 +183,7 @@ describe('OrderStateWatcher', () => {
done();
}
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.fillOrderAsync(
@@ -223,7 +220,7 @@ describe('OrderStateWatcher', () => {
done();
}
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.fillOrderAsync(
signedOrder, fillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, taker,
@@ -324,7 +321,7 @@ describe('OrderStateWatcher', () => {
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
done();
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
@@ -351,7 +348,7 @@ describe('OrderStateWatcher', () => {
expect(orderRelevantState.canceledTakerTokenAmount).to.be.bignumber.equal(cancelAmountInBaseUnits);
done();
});
- zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.orderStateWatcher.subscribeAsync(callback);
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmountInBaseUnits);
})().catch(done);
});