forked from smartcontractkit/external-adapters-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.ts
74 lines (69 loc) · 1.71 KB
/
fixtures.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import nock from 'nock'
export const mockResponseSuccessConvertEndpoint = (): nock =>
nock('https://api.1forge.com', {
encodedQueryParams: true,
})
.get('/convert')
.query({ api_key: 'fake-api-key', from: 'USD', to: 'EUR', quantity: 1 })
.reply(
200,
(_, request) => ({
value: '0.862701',
text: '1 USD is worth 0.862701 EUR',
timestamp: 1636478097478,
}),
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)
export const mockResponseSuccessQuotesEnpoint = (): nock =>
nock('https://api.1forge.com', {
encodedQueryParams: true,
})
.get('/quotes')
.query({ api_key: 'fake-api-key', pairs: 'USD/EUR' })
.reply(
200,
(_, request) => [
{
p: 0.8828,
a: 0.8828,
b: 0.8827,
s: 'USD/EUR',
t: 1641851954307,
},
],
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)
export const mockLoginResponse = {
request: 'login|fake-api-key',
response: [
'message|Connected to 1Forge Socket Server. If you need help, please email [email protected]',
'message|You are currently using 1 out of 10 sessions',
'post_login_success|undefined',
],
}
export const mockSubscribeResponse = {
request: 'subscribe_to|USD/EUR',
response: 'update|{"p":0.88935,"a":0.88938,"b":0.88932,"s":"USD/EUR","t":1645811011686}',
}
export const mockUnsubscribeResponse = {
request: 'unsubscribe_from|USD/EUR',
response: '',
}