@@ -50,4 +50,50 @@ describe('subscriptions mappers', () => {
5050 { channel : 'V1TAIndexPrice' , symbols : [ 'BTC' ] }
5151 ] )
5252 } )
53+
54+ test ( 'maps Polymarket market subscriptions' , ( ) => {
55+ const mapper = subscriptionsMappers . polymarket
56+ const date = new Date ( )
57+ const message = { type : 'market' , assets_ids : [ '2174101397' , '713210352' ] }
58+
59+ expect ( mapper . canHandle ( message , date ) ) . toBe ( true )
60+ expect ( mapper . map ( message , date ) ) . toEqual ( [
61+ { channel : 'book' , symbols : [ '2174101397' , '713210352' ] } ,
62+ { channel : 'price_change' , symbols : [ '2174101397' , '713210352' ] } ,
63+ { channel : 'last_trade_price' , symbols : [ '2174101397' , '713210352' ] } ,
64+ { channel : 'tick_size_change' , symbols : [ '2174101397' , '713210352' ] }
65+ ] )
66+ } )
67+
68+ test ( 'maps Polymarket custom market subscriptions' , ( ) => {
69+ const mapper = subscriptionsMappers . polymarket
70+ const date = new Date ( )
71+ const message = { type : 'market' , assets_ids : [ '2174101397' ] , custom_feature_enabled : true }
72+
73+ expect ( mapper . map ( message , date ) ) . toEqual ( [
74+ { channel : 'book' , symbols : [ '2174101397' ] } ,
75+ { channel : 'price_change' , symbols : [ '2174101397' ] } ,
76+ { channel : 'last_trade_price' , symbols : [ '2174101397' ] } ,
77+ { channel : 'tick_size_change' , symbols : [ '2174101397' ] } ,
78+ { channel : 'best_bid_ask' , symbols : [ '2174101397' ] } ,
79+ { channel : 'new_market' , symbols : [ '2174101397' ] } ,
80+ { channel : 'market_resolved' , symbols : [ '2174101397' ] }
81+ ] )
82+ } )
83+
84+ test ( 'maps Polymarket empty asset subscriptions' , ( ) => {
85+ const mapper = subscriptionsMappers . polymarket
86+ const date = new Date ( )
87+ const message = { type : 'market' , assets_ids : [ ] , custom_feature_enabled : true }
88+
89+ expect ( mapper . map ( message , date ) ) . toEqual ( [
90+ { channel : 'book' , symbols : [ ] } ,
91+ { channel : 'price_change' , symbols : [ ] } ,
92+ { channel : 'last_trade_price' , symbols : [ ] } ,
93+ { channel : 'tick_size_change' , symbols : [ ] } ,
94+ { channel : 'best_bid_ask' , symbols : [ ] } ,
95+ { channel : 'new_market' , symbols : [ ] } ,
96+ { channel : 'market_resolved' , symbols : [ ] }
97+ ] )
98+ } )
5399} )
0 commit comments