@@ -38,7 +38,7 @@ describe('WSv2 utilities', () => {
38
38
const listener = listenerSet . trade [ 0 ]
39
39
40
40
assert . strictEqual ( listener . modelClass , Map )
41
- assert . deepStrictEqual ( listener . filter , { '2' : 'tBTCUSD' } )
41
+ assert . deepStrictEqual ( listener . filter , { 2 : 'tBTCUSD' } )
42
42
assert . strictEqual ( typeof listener . cb , 'function' )
43
43
} )
44
44
@@ -349,7 +349,7 @@ describe('WSv2 auto reconnect', () => {
349
349
350
350
ws . on ( 'open' , ws . auth . bind ( ws ) )
351
351
ws . once ( 'auth' , ( ) => {
352
- let now = Date . now ( )
352
+ const now = Date . now ( )
353
353
354
354
ws . reconnectAfterClose = ( ) => {
355
355
assert ( ( Date . now ( ) - now ) >= 70 )
@@ -674,16 +674,16 @@ describe('WSv2 channel msg handling', () => {
674
674
675
675
const lg = {
676
676
'' : [ { cb : func } ] ,
677
- ' test' : [ { cb : func } ] ,
678
- ' nope' : [ { cb : func } ]
677
+ test : [ { cb : func } ] ,
678
+ nope : [ { cb : func } ]
679
679
}
680
680
681
681
WSv2 . _notifyListenerGroup ( lg , [ 0 , 'test' , [ 0 , 'tu' ] ] , false )
682
682
} )
683
683
684
684
it ( '_notifyListenerGroup: doesn\'t fail on missing data if filtering' , ( done ) => {
685
685
const lg = {
686
- ' test' : [ {
686
+ test : [ {
687
687
filter : { 1 : 'on' } ,
688
688
cb : ( ) => {
689
689
done ( new Error ( 'filter should not have matched' ) )
@@ -726,14 +726,18 @@ describe('WSv2 channel msg handling', () => {
726
726
transform : true
727
727
} )
728
728
729
- ws . _channelMapA = { 42 : {
730
- channel : 'orderbook' ,
731
- symbol : 'tBTCUSD'
732
- } }
733
- ws . _channelMapB = { 43 : {
734
- channel : 'orderbook' ,
735
- symbol : 'fUSD'
736
- } }
729
+ ws . _channelMapA = {
730
+ 42 : {
731
+ channel : 'orderbook' ,
732
+ symbol : 'tBTCUSD'
733
+ }
734
+ }
735
+ ws . _channelMapB = {
736
+ 43 : {
737
+ channel : 'orderbook' ,
738
+ symbol : 'fUSD'
739
+ }
740
+ }
737
741
738
742
ws . _handleOBMessage ( [ 42 , [
739
743
[ 100 , 2 , - 4 ] ,
@@ -778,10 +782,12 @@ describe('WSv2 channel msg handling', () => {
778
782
transform : true
779
783
} )
780
784
781
- wsNoTransform . _channelMap = { 42 : {
782
- channel : 'orderbook' ,
783
- symbol : 'tBTCUSD'
784
- } }
785
+ wsNoTransform . _channelMap = {
786
+ 42 : {
787
+ channel : 'orderbook' ,
788
+ symbol : 'tBTCUSD'
789
+ }
790
+ }
785
791
786
792
wsTransform . _channelMap = wsNoTransform . _channelMap
787
793
@@ -801,10 +807,12 @@ describe('WSv2 channel msg handling', () => {
801
807
802
808
it ( '_handleOBMessage: forwards managed ob to listeners' , ( done ) => {
803
809
const ws = new WSv2 ( { manageOrderBooks : true } )
804
- ws . _channelMap = { 42 : {
805
- channel : 'orderbook' ,
806
- symbol : 'tBTCUSD'
807
- } }
810
+ ws . _channelMap = {
811
+ 42 : {
812
+ channel : 'orderbook' ,
813
+ symbol : 'tBTCUSD'
814
+ }
815
+ }
808
816
809
817
let seen = 0
810
818
ws . onOrderBook ( { symbol : 'tBTCUSD' } , ( ob ) => {
@@ -861,10 +869,12 @@ describe('WSv2 channel msg handling', () => {
861
869
862
870
it ( '_handleOBMessage: emits managed ob' , ( done ) => {
863
871
const ws = new WSv2 ( { manageOrderBooks : true } )
864
- ws . _channelMap = { 42 : {
865
- channel : 'orderbook' ,
866
- symbol : 'tBTCUSD'
867
- } }
872
+ ws . _channelMap = {
873
+ 42 : {
874
+ channel : 'orderbook' ,
875
+ symbol : 'tBTCUSD'
876
+ }
877
+ }
868
878
869
879
ws . on ( 'orderbook' , ( symbol , data ) => {
870
880
assert . strictEqual ( symbol , 'tBTCUSD' )
@@ -877,11 +887,13 @@ describe('WSv2 channel msg handling', () => {
877
887
878
888
it ( '_handleOBMessage: forwards transformed data if transform enabled' , ( done ) => {
879
889
const ws = new WSv2 ( { transform : true } )
880
- ws . _channelMap = { 42 : {
881
- chanId : 42 ,
882
- channel : 'orderbook' ,
883
- symbol : 'tBTCUSD'
884
- } }
890
+ ws . _channelMap = {
891
+ 42 : {
892
+ chanId : 42 ,
893
+ channel : 'orderbook' ,
894
+ symbol : 'tBTCUSD'
895
+ }
896
+ }
885
897
886
898
ws . onOrderBook ( { symbol : 'tBTCUSD' } , ( ob ) => {
887
899
assert ( ob . asks )
@@ -940,10 +952,12 @@ describe('WSv2 channel msg handling', () => {
940
952
941
953
it ( '_handleCandleMessage: maintains internal candles if management is enabled' , ( ) => {
942
954
const ws = new WSv2 ( { manageCandles : true } )
943
- ws . _channelMap = { 64 : {
944
- channel : 'candles' ,
945
- key : 'trade:1m:tBTCUSD'
946
- } }
955
+ ws . _channelMap = {
956
+ 64 : {
957
+ channel : 'candles' ,
958
+ key : 'trade:1m:tBTCUSD'
959
+ }
960
+ }
947
961
948
962
ws . _handleCandleMessage ( [ 64 , [
949
963
[ 5 , 100 , 70 , 150 , 30 , 1000 ] ,
@@ -1014,11 +1028,13 @@ describe('WSv2 channel msg handling', () => {
1014
1028
1015
1029
it ( '_handleCandleMessage: forwards managed candles to listeners' , ( done ) => {
1016
1030
const ws = new WSv2 ( { manageCandles : true } )
1017
- ws . _channelMap = { 42 : {
1018
- chanId : 42 ,
1019
- channel : 'candles' ,
1020
- key : 'trade:1m:tBTCUSD'
1021
- } }
1031
+ ws . _channelMap = {
1032
+ 42 : {
1033
+ chanId : 42 ,
1034
+ channel : 'candles' ,
1035
+ key : 'trade:1m:tBTCUSD'
1036
+ }
1037
+ }
1022
1038
1023
1039
let seen = 0
1024
1040
ws . onCandle ( { key : 'trade:1m:tBTCUSD' } , ( data ) => {
@@ -1039,10 +1055,12 @@ describe('WSv2 channel msg handling', () => {
1039
1055
1040
1056
it ( '_handleCandleMessage: emits managed candles' , ( done ) => {
1041
1057
const ws = new WSv2 ( { manageCandles : true } )
1042
- ws . _channelMap = { 42 : {
1043
- channel : 'candles' ,
1044
- key : 'trade:1m:tBTCUSD'
1045
- } }
1058
+ ws . _channelMap = {
1059
+ 42 : {
1060
+ channel : 'candles' ,
1061
+ key : 'trade:1m:tBTCUSD'
1062
+ }
1063
+ }
1046
1064
1047
1065
ws . on ( 'candle' , ( data , key ) => {
1048
1066
assert . strictEqual ( key , 'trade:1m:tBTCUSD' )
@@ -1058,11 +1076,13 @@ describe('WSv2 channel msg handling', () => {
1058
1076
1059
1077
it ( '_handleCandleMessage: forwards transformed data if transform enabled' , ( done ) => {
1060
1078
const ws = new WSv2 ( { transform : true } )
1061
- ws . _channelMap = { 42 : {
1062
- chanId : 42 ,
1063
- channel : 'candles' ,
1064
- key : 'trade:1m:tBTCUSD'
1065
- } }
1079
+ ws . _channelMap = {
1080
+ 42 : {
1081
+ chanId : 42 ,
1082
+ channel : 'candles' ,
1083
+ key : 'trade:1m:tBTCUSD'
1084
+ }
1085
+ }
1066
1086
1067
1087
ws . onCandle ( { key : 'trade:1m:tBTCUSD' } , ( candles ) => {
1068
1088
assert . strictEqual ( candles . length , 1 )
0 commit comments