Skip to content

Commit afeb0a7

Browse files
update test
1 parent 26204e2 commit afeb0a7

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

packages/sources/tiingo/test/integration/__snapshots__/adapter-ws.test.ts.snap

+34
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,40 @@ exports[`websocket crypto endpoint should return success 1`] = `
1515
}
1616
`;
1717

18+
exports[`websocket crypto_lwba endpoint should only subscribe once 1`] = `
19+
{
20+
"data": {
21+
"ask": 1794.2063137650225,
22+
"bid": 1793.6242715443277,
23+
"mid": 1793.915292654675,
24+
},
25+
"result": null,
26+
"statusCode": 200,
27+
"timestamps": {
28+
"providerDataReceivedUnixMs": 2028,
29+
"providerDataStreamEstablishedUnixMs": 2020,
30+
"providerIndicatedTimeUnixMs": 1680187094577,
31+
},
32+
}
33+
`;
34+
35+
exports[`websocket crypto_lwba endpoint should only subscribe once 2`] = `
36+
{
37+
"data": {
38+
"ask": 1794.2063137650225,
39+
"bid": 1793.6242715443277,
40+
"mid": 1793.915292654675,
41+
},
42+
"result": null,
43+
"statusCode": 200,
44+
"timestamps": {
45+
"providerDataReceivedUnixMs": 2028,
46+
"providerDataStreamEstablishedUnixMs": 2020,
47+
"providerIndicatedTimeUnixMs": 1680187094577,
48+
},
49+
}
50+
`;
51+
1852
exports[`websocket crypto_lwba endpoint should return error (invariant violation) 1`] = `
1953
{
2054
"error": {

packages/sources/tiingo/test/integration/adapter-ws.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
} from './fixtures'
1414
import { WebSocketClassProvider } from '@chainlink/external-adapter-framework/transports'
1515
import FakeTimers from '@sinonjs/fake-timers'
16+
import * as lwbaTransport from '../../src/transport/crypto-lwba'
17+
import * as lwbaEndpoint from '../../src/endpoint/crypto-lwba'
1618

1719
describe('websocket', () => {
1820
let mockWsServerCrypto: MockWebsocketServer | undefined
@@ -100,6 +102,25 @@ describe('websocket', () => {
100102
const response = await testAdapter.request(spreadData)
101103
expect(response.json()).toMatchSnapshot()
102104
})
105+
it('should only subscribe once', async () => {
106+
const lwbaDataLowercase = {
107+
endpoint: 'crypto_lwba',
108+
base: 'eth',
109+
quote: 'usd',
110+
}
111+
const lwbaDataUppercase = {
112+
endpoint: 'crypto_lwba',
113+
base: 'ETH',
114+
quote: 'USD',
115+
}
116+
const response1 = await testAdapter.request(lwbaDataLowercase)
117+
expect(response1.json()).toMatchSnapshot()
118+
119+
const response2 = await testAdapter.request(lwbaDataUppercase)
120+
expect(response2.json()).toMatchSnapshot()
121+
122+
expect(lwbaTransport.transport.subscriptionSet.getAll()).toHaveLength(1)
123+
})
103124
it('should return error (invariant violation)', async () => {
104125
// fast forward to next message (which contains an invariant violation)
105126
testAdapter.clock.tick(5000)

0 commit comments

Comments
 (0)