1- import { getOrderBuilder$ , CEXorder } from './order-builder' ;
2- import { TestScheduler } from 'rxjs/testing' ;
3- import { testConfig , getLoggers } from '../test-utils' ;
4- import { Observable } from 'rxjs' ;
5- import { SwapSuccess } from '../proto/xudrpc_pb' ;
6- import { OrderSide , Asset } from '../constants' ;
71import BigNumber from 'bignumber.js' ;
2+ import { Observable } from 'rxjs' ;
3+ import { TestScheduler } from 'rxjs/testing' ;
84import { Config } from '../config' ;
5+ import { Asset , OrderSide } from '../constants' ;
6+ import { SwapSuccess } from '../proto/xudrpc_pb' ;
7+ import { ArbyStore , getArbyStore } from '../store' ;
8+ import { getLoggers , testConfig } from '../test-utils' ;
9+ import { CEXorder , getOrderBuilder$ } from './order-builder' ;
910
1011let testScheduler : TestScheduler ;
1112
@@ -28,7 +29,8 @@ const assertOrderBuilder = (
2829 a : CEXorder ;
2930 } ,
3031 config : Config ,
31- expectedAssetToTradeOnCEX : Asset
32+ expectedAssetToTradeOnCEX : Asset ,
33+ store ?: ArbyStore
3234) => {
3335 testScheduler . run ( helpers => {
3436 const { cold, expectObservable } = helpers ;
@@ -59,6 +61,7 @@ const assertOrderBuilder = (
5961 accumulateOrderFillsForBaseAssetReceived : accumulateOrderFillsForAssetReceived ,
6062 accumulateOrderFillsForQuoteAssetReceived : accumulateOrderFillsForAssetReceived ,
6163 quantityAboveMinimum,
64+ store : store ? store : getArbyStore ( ) ,
6265 } ) ;
6366 expectObservable ( orderBuilder$ , inputEvents . unsubscribe ) . toBe (
6467 expected ,
@@ -83,6 +86,7 @@ describe('getCentralizedExchangeOrder$', () => {
8386 } ) ;
8487
8588 it ( 'accumulates buy and sell orders for ETHBTC' , ( ) => {
89+ expect . assertions ( 6 ) ;
8690 const inputEvents = {
8791 receivedBaseAssetSwapSuccess$ : '1s a' ,
8892 receivedQuoteAssetSwapSuccess$ : '1400ms b' ,
@@ -117,17 +121,24 @@ describe('getCentralizedExchangeOrder$', () => {
117121 QUOTEASSET ,
118122 } ;
119123 const expectedAssetToTradeOnCEX = BASEASSET ;
124+ const store = {
125+ ...getArbyStore ( ) ,
126+ ...{ resetLastOrderUpdatePrice : jest . fn ( ) } ,
127+ } ;
120128 assertOrderBuilder (
121129 inputEvents ,
122130 inputValues ,
123131 expected ,
124132 expectedValues ,
125133 config ,
126- expectedAssetToTradeOnCEX
134+ expectedAssetToTradeOnCEX ,
135+ store
127136 ) ;
137+ expect ( store . resetLastOrderUpdatePrice ) . toHaveBeenCalledTimes ( 2 ) ;
128138 } ) ;
129139
130140 it ( 'accumulates buy and sell orders for BTCUSDT' , ( ) => {
141+ expect . assertions ( 6 ) ;
131142 const inputEvents = {
132143 receivedBaseAssetSwapSuccess$ : '1s a' ,
133144 receivedQuoteAssetSwapSuccess$ : '1400ms b' ,
@@ -162,13 +173,19 @@ describe('getCentralizedExchangeOrder$', () => {
162173 QUOTEASSET ,
163174 } ;
164175 const expectedAssetToTradeOnCEX = QUOTEASSET ;
176+ const store = {
177+ ...getArbyStore ( ) ,
178+ ...{ resetLastOrderUpdatePrice : jest . fn ( ) } ,
179+ } ;
165180 assertOrderBuilder (
166181 inputEvents ,
167182 inputValues ,
168183 expected ,
169184 expectedValues ,
170185 config ,
171- expectedAssetToTradeOnCEX
186+ expectedAssetToTradeOnCEX ,
187+ store
172188 ) ;
189+ expect ( store . resetLastOrderUpdatePrice ) . toHaveBeenCalledTimes ( 2 ) ;
173190 } ) ;
174191} ) ;
0 commit comments