aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-watcher/test')
-rw-r--r--packages/order-watcher/test/global_hooks.ts2
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts4
-rw-r--r--packages/order-watcher/test/utils/token_utils.ts34
3 files changed, 37 insertions, 3 deletions
diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts
index 4552e01b0..f64f1df78 100644
--- a/packages/order-watcher/test/global_hooks.ts
+++ b/packages/order-watcher/test/global_hooks.ts
@@ -7,7 +7,7 @@ before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
const mochaTestTimeoutMs = 25000;
- this.timeout(mochaTestTimeoutMs);
+ this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
const txDefaults = {
gas: devConstants.GAS_LIMIT,
from: devConstants.TESTRPC_FIRST_ADDRESS,
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 6339505ce..1281d11c2 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -136,8 +136,8 @@ describe('OrderWatcher', () => {
orderWatcher.unsubscribe();
});
it('should fail when trying to subscribe twice', async () => {
- orderWatcher.subscribe(_.noop);
- expect(() => orderWatcher.subscribe(_.noop)).to.throw(OrderWatcherError.SubscriptionAlreadyPresent);
+ orderWatcher.subscribe(_.noop.bind(_));
+ expect(() => orderWatcher.subscribe(_.noop.bind(_))).to.throw(OrderWatcherError.SubscriptionAlreadyPresent);
});
});
describe('tests with cleanup', async () => {
diff --git a/packages/order-watcher/test/utils/token_utils.ts b/packages/order-watcher/test/utils/token_utils.ts
new file mode 100644
index 000000000..f91b3797f
--- /dev/null
+++ b/packages/order-watcher/test/utils/token_utils.ts
@@ -0,0 +1,34 @@
+import { Token } from '@0xproject/types';
+import * as _ from 'lodash';
+
+import { InternalOrderWatcherError } from '../../src/types';
+
+const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
+const WETH_TOKEN_SYMBOL = 'WETH';
+
+export class TokenUtils {
+ private readonly _tokens: Token[];
+ constructor(tokens: Token[]) {
+ this._tokens = tokens;
+ }
+ public getProtocolTokenOrThrow(): Token {
+ const zrxToken = _.find(this._tokens, { symbol: PROTOCOL_TOKEN_SYMBOL });
+ if (_.isUndefined(zrxToken)) {
+ throw new Error(InternalOrderWatcherError.ZrxNotInTokenRegistry);
+ }
+ return zrxToken;
+ }
+ public getWethTokenOrThrow(): Token {
+ const wethToken = _.find(this._tokens, { symbol: WETH_TOKEN_SYMBOL });
+ if (_.isUndefined(wethToken)) {
+ throw new Error(InternalOrderWatcherError.WethNotInTokenRegistry);
+ }
+ return wethToken;
+ }
+ public getDummyTokens(): Token[] {
+ const dummyTokens = _.filter(this._tokens, token => {
+ return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
+ });
+ return dummyTokens;
+ }
+}