aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
});