@@ -44,7 +44,12 @@ describe('websocket', () => {
44
44
process . env [ 'METRICS_ENABLED' ] = 'false'
45
45
// Start mock web socket server
46
46
mockWebSocketProvider ( WebSocketClassProvider )
47
- mockWebSocketServer ( `wss://api.chk.elwood.systems/v1/stream?apiKey${ process . env [ 'API_KEY' ] } ` )
47
+ mockWsServer = mockWebSocketServer (
48
+ `wss://api.chk.elwood.systems/v1/stream?apiKey${ process . env [ 'API_KEY' ] } ` ,
49
+ )
50
+
51
+ mockSubscriptionsResponse ( apiKey , [ ] )
52
+ mockSubscribeResponse ( apiKey , `${ data . base } -${ data . quote } ` )
48
53
49
54
const adapter = ( await import ( './../../src' ) ) . adapter
50
55
testAdapter = await TestAdapter . startWithMockedCache ( adapter , {
@@ -63,11 +68,9 @@ describe('websocket', () => {
63
68
64
69
describe ( 'price endpoint' , ( ) => {
65
70
it ( 'should return success' , async ( ) => {
66
- mockSubscriptionsResponse ( apiKey , [ ] )
67
- const scope = mockSubscribeResponse ( apiKey , `${ data . base } -${ data . quote } ` )
68
71
const response = await testAdapter . request ( data )
72
+
69
73
expect ( response . json ( ) ) . toMatchSnapshot ( )
70
- expect ( scope . isDone ( ) ) . toEqual ( true )
71
74
} )
72
75
73
76
it ( 'should skip subscribing if already subscribed' , async ( ) => {
@@ -80,14 +83,12 @@ describe('websocket', () => {
80
83
} )
81
84
82
85
it ( 'should return success (LWBA)' , async ( ) => {
83
- mockSubscriptionsResponse ( apiKey , [ ] )
84
86
mockSubscribeResponse ( apiKey , `${ dataLWBA . base } -${ dataLWBA . quote } ` )
85
87
const response = await testAdapter . request ( dataLWBA )
86
88
expect ( response . json ( ) ) . toMatchSnapshot ( )
87
89
} )
88
90
89
91
it ( 'should return error (LWBA invariant violation)' , async ( ) => {
90
- mockSubscriptionsResponse ( apiKey , [ ] )
91
92
mockSubscribeResponse (
92
93
apiKey ,
93
94
`${ dataLWBAInvariantViolation . base } -${ dataLWBAInvariantViolation . quote } ` ,
@@ -101,7 +102,6 @@ describe('websocket', () => {
101
102
base : 'XXX' ,
102
103
quote : 'USD' ,
103
104
}
104
- mockSubscriptionsResponse ( apiKey , [ ] )
105
105
mockSubscribeError ( apiKey , `${ data . base } -${ data . quote } ` )
106
106
await testAdapter . request ( data )
107
107
await testAdapter . waitForCache ( )
0 commit comments