@chainlink/external-adapter-framework 0.0.22 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache/factory.js +27 -0
- package/cache/index.js +16 -1
- package/cache/local.js +26 -0
- package/cache/redis.js +45 -0
- package/config/index.d.ts +1 -1
- package/examples/coingecko/src/globalUtils.d.ts +1 -1
- package/examples/coingecko/src/index.d.ts +1 -1
- package/index.d.ts +1 -1
- package/metrics/index.d.ts +1 -1
- package/package.json +2 -2
- package/rate-limiting/index.d.ts +2 -2
- package/transports/batch-warming.js +36 -0
- package/transports/metrics.d.ts +1 -1
- package/transports/rest.js +32 -0
- package/transports/util.js +33 -0
- package/transports/websocket.js +31 -0
- package/examples/coingecko/batch-warming.d.ts +0 -7
- package/examples/coingecko/batch-warming.js +0 -53
- package/examples/coingecko/index.d.ts +0 -2
- package/examples/coingecko/index.js +0 -11
- package/examples/coingecko/rest.d.ts +0 -12
- package/examples/coingecko/rest.js +0 -51
- package/examples/coingecko/test/e2e/adapter.test.js +0 -262
- package/examples/coingecko/test/integration/adapter.test.js +0 -264
- package/examples/coingecko/test/integration/capturedRequests.json +0 -1
- package/examples/coingecko/test/integration/fixtures.js +0 -41
- package/test.d.ts +0 -1
- package/test.js +0 -6
- package/util/recordRequests.js +0 -45
- package/validation/overrideFunctions.js +0 -40
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.restEndpoint = void 0;
|
|
4
|
-
const adapter_1 = require("../../adapter");
|
|
5
|
-
const transports_1 = require("../../transports");
|
|
6
|
-
const DEFAULT_URL = 'https://api.coingecko.com/api/v3';
|
|
7
|
-
const inputParameters = {
|
|
8
|
-
coinid: {
|
|
9
|
-
description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
|
|
10
|
-
required: false,
|
|
11
|
-
},
|
|
12
|
-
base: {
|
|
13
|
-
aliases: ['from', 'coin'],
|
|
14
|
-
description: 'The symbol or array of symbols of the currency to query',
|
|
15
|
-
required: true,
|
|
16
|
-
},
|
|
17
|
-
quote: {
|
|
18
|
-
aliases: ['to', 'market'],
|
|
19
|
-
description: 'The symbol of the currency to convert to',
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const restEndpointTransport = new transports_1.RestTransport({
|
|
24
|
-
prepareRequest: (req) => {
|
|
25
|
-
return {
|
|
26
|
-
baseURL: DEFAULT_URL,
|
|
27
|
-
url: '/simple/price',
|
|
28
|
-
method: 'GET',
|
|
29
|
-
params: {
|
|
30
|
-
ids: req.requestContext.data.base,
|
|
31
|
-
vs_currencies: req.requestContext.data.quote,
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
parseResponse: (req, res) => {
|
|
36
|
-
return {
|
|
37
|
-
data: res.data,
|
|
38
|
-
statusCode: 200,
|
|
39
|
-
result: res.data[req.requestContext.data.base]?.[req.requestContext.data.quote],
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
options: {
|
|
43
|
-
coalescing: true,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
exports.restEndpoint = new adapter_1.AdapterEndpoint({
|
|
47
|
-
name: 'rest',
|
|
48
|
-
aliases: ['qwe'],
|
|
49
|
-
transport: restEndpointTransport,
|
|
50
|
-
inputParameters,
|
|
51
|
-
});
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable max-nested-callbacks */
|
|
7
|
-
const index_1 = require("../../src/index");
|
|
8
|
-
const __1 = require("../../../..");
|
|
9
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
10
|
-
let adapterServer;
|
|
11
|
-
function sleep(ms) {
|
|
12
|
-
// eslint-disable-next-line
|
|
13
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
-
}
|
|
15
|
-
describe('execute', () => {
|
|
16
|
-
const id = '1';
|
|
17
|
-
let req;
|
|
18
|
-
jest.setTimeout(10000);
|
|
19
|
-
const successfulRequests = {
|
|
20
|
-
crypto: {
|
|
21
|
-
id,
|
|
22
|
-
data: {
|
|
23
|
-
base: 'ETH',
|
|
24
|
-
quote: 'USD',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
cryptoWithCoinid: {
|
|
28
|
-
id,
|
|
29
|
-
data: {
|
|
30
|
-
coinid: 'bitcoin',
|
|
31
|
-
quote: 'USD',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
cryptoWithOverride: {
|
|
35
|
-
id,
|
|
36
|
-
data: {
|
|
37
|
-
base: 'BTC',
|
|
38
|
-
quote: 'EUR',
|
|
39
|
-
overrides: {
|
|
40
|
-
coingecko: {
|
|
41
|
-
BTC: 'solana',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
coins: {
|
|
47
|
-
id,
|
|
48
|
-
endpoint: 'coins',
|
|
49
|
-
},
|
|
50
|
-
marketcap: {
|
|
51
|
-
id,
|
|
52
|
-
endpoint: 'marketcap',
|
|
53
|
-
data: {
|
|
54
|
-
base: 'ETH',
|
|
55
|
-
quote: 'USD',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
volume: {
|
|
59
|
-
id,
|
|
60
|
-
endpoint: 'volume',
|
|
61
|
-
data: {
|
|
62
|
-
base: 'ETH',
|
|
63
|
-
quote: 'USD',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
globalmarketcap: {
|
|
67
|
-
id,
|
|
68
|
-
endpoint: 'globalmarketcap',
|
|
69
|
-
data: {
|
|
70
|
-
market: 'ETH',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
dominance: {
|
|
74
|
-
id,
|
|
75
|
-
endpoint: 'dominance',
|
|
76
|
-
data: {
|
|
77
|
-
market: 'ETH',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
const errorRequests = {
|
|
82
|
-
cryptoWithBadSymbol: {
|
|
83
|
-
id,
|
|
84
|
-
data: {
|
|
85
|
-
base: 'ZWXK',
|
|
86
|
-
quote: 'USD',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
cryptoWithBadOverride: {
|
|
90
|
-
id,
|
|
91
|
-
data: {
|
|
92
|
-
base: 'LINK',
|
|
93
|
-
quote: 'USD',
|
|
94
|
-
overrides: {
|
|
95
|
-
coingecko: {
|
|
96
|
-
LINK: 'badtokenid',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
dominanceWithBadSymbol: {
|
|
102
|
-
id,
|
|
103
|
-
endpoint: 'dominance',
|
|
104
|
-
data: {
|
|
105
|
-
market: 'ZWXK',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
beforeAll(async () => {
|
|
110
|
-
try {
|
|
111
|
-
adapterServer = await (0, __1.expose)(index_1.adapter);
|
|
112
|
-
req = (0, supertest_1.default)('localhost:8080');
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
116
|
-
}
|
|
117
|
-
if (!adapterServer) {
|
|
118
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
119
|
-
}
|
|
120
|
-
// Send inital requests to warm the cache
|
|
121
|
-
const pendingRequests = [];
|
|
122
|
-
for (const reqData of Object.values(successfulRequests)) {
|
|
123
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
124
|
-
}
|
|
125
|
-
for (const reqData of Object.values(errorRequests)) {
|
|
126
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
127
|
-
}
|
|
128
|
-
// Wait for all the pending requests to be complete
|
|
129
|
-
Promise.all(pendingRequests);
|
|
130
|
-
// Sleep while the cache is filled
|
|
131
|
-
await sleep(5000);
|
|
132
|
-
});
|
|
133
|
-
afterAll((done) => {
|
|
134
|
-
if (adapterServer) {
|
|
135
|
-
adapterServer.close(done());
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
describe('crypto api', () => {
|
|
139
|
-
it('should return success', async () => {
|
|
140
|
-
// Send inital request to warm cache
|
|
141
|
-
const response = await req
|
|
142
|
-
.post('/')
|
|
143
|
-
.send(successfulRequests.crypto)
|
|
144
|
-
.set('Accept', '*/*')
|
|
145
|
-
.set('Content-Type', 'application/json')
|
|
146
|
-
.expect(200);
|
|
147
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
148
|
-
});
|
|
149
|
-
it('should return success with coinid', async () => {
|
|
150
|
-
const response = await req
|
|
151
|
-
.post('/')
|
|
152
|
-
.send(successfulRequests.cryptoWithCoinid)
|
|
153
|
-
.set('Accept', '*/*')
|
|
154
|
-
.set('Content-Type', 'application/json')
|
|
155
|
-
.expect('Content-Type', /json/)
|
|
156
|
-
.expect(200);
|
|
157
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
158
|
-
});
|
|
159
|
-
it('should return error message for bad symbol', async () => {
|
|
160
|
-
await req
|
|
161
|
-
.post('/')
|
|
162
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
163
|
-
.set('Accept', '*/*')
|
|
164
|
-
.set('Content-Type', 'application/json')
|
|
165
|
-
.expect(504);
|
|
166
|
-
});
|
|
167
|
-
it('should return success with override', async () => {
|
|
168
|
-
const response = await req
|
|
169
|
-
.post('/')
|
|
170
|
-
.send(successfulRequests.cryptoWithOverride)
|
|
171
|
-
.set('Accept', '*/*')
|
|
172
|
-
.set('Content-Type', 'application/json')
|
|
173
|
-
.expect('Content-Type', /json/)
|
|
174
|
-
.expect(200);
|
|
175
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
176
|
-
});
|
|
177
|
-
it('should return 504 for bad override', async () => {
|
|
178
|
-
const response = await req
|
|
179
|
-
.post('/')
|
|
180
|
-
.send(errorRequests.cryptoWithBadOverride)
|
|
181
|
-
.set('Accept', '*/*')
|
|
182
|
-
.set('Content-Type', 'application/json')
|
|
183
|
-
.expect(504);
|
|
184
|
-
expect(typeof response.body.result === 'string');
|
|
185
|
-
});
|
|
186
|
-
it('should return 504 for bad symbol', async () => {
|
|
187
|
-
await req
|
|
188
|
-
.post('/')
|
|
189
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
190
|
-
.set('Accept', '*/*')
|
|
191
|
-
.set('Content-Type', 'application/json')
|
|
192
|
-
.expect(504);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe('coins api', () => {
|
|
196
|
-
it('should return success', async () => {
|
|
197
|
-
await req
|
|
198
|
-
.post('/')
|
|
199
|
-
.send(successfulRequests.coins)
|
|
200
|
-
.set('Accept', '*/*')
|
|
201
|
-
.set('Content-Type', 'application/json')
|
|
202
|
-
.expect('Content-Type', /json/)
|
|
203
|
-
.expect(200);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
describe('volume api', () => {
|
|
207
|
-
it('should return success', async () => {
|
|
208
|
-
const response = await req
|
|
209
|
-
.post('/')
|
|
210
|
-
.send(successfulRequests.volume)
|
|
211
|
-
.set('Accept', '*/*')
|
|
212
|
-
.set('Content-Type', 'application/json')
|
|
213
|
-
.expect('Content-Type', /json/)
|
|
214
|
-
.expect(200);
|
|
215
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
describe('marketcap api', () => {
|
|
219
|
-
it('should return success', async () => {
|
|
220
|
-
const response = await req
|
|
221
|
-
.post('/')
|
|
222
|
-
.send(successfulRequests.marketcap)
|
|
223
|
-
.set('Accept', '*/*')
|
|
224
|
-
.set('Content-Type', 'application/json')
|
|
225
|
-
.expect('Content-Type', /json/)
|
|
226
|
-
.expect(200);
|
|
227
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
describe('globalmarketcap api', () => {
|
|
231
|
-
it('should return success', async () => {
|
|
232
|
-
const response = await req
|
|
233
|
-
.post('/')
|
|
234
|
-
.send(successfulRequests.globalmarketcap)
|
|
235
|
-
.set('Accept', '*/*')
|
|
236
|
-
.set('Content-Type', 'application/json')
|
|
237
|
-
.expect('Content-Type', /json/)
|
|
238
|
-
.expect(200);
|
|
239
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
describe('dominance api', () => {
|
|
243
|
-
it('should return success', async () => {
|
|
244
|
-
const response = await req
|
|
245
|
-
.post('/')
|
|
246
|
-
.send(successfulRequests.dominance)
|
|
247
|
-
.set('Accept', '*/*')
|
|
248
|
-
.set('Content-Type', 'application/json')
|
|
249
|
-
.expect('Content-Type', /json/)
|
|
250
|
-
.expect(200);
|
|
251
|
-
expect(response.body.result).toBeGreaterThan(0);
|
|
252
|
-
});
|
|
253
|
-
it('should return 504 for bad symbol', async () => {
|
|
254
|
-
await req
|
|
255
|
-
.post('/')
|
|
256
|
-
.send(errorRequests.dominanceWithBadSymbol)
|
|
257
|
-
.set('Accept', '*/*')
|
|
258
|
-
.set('Content-Type', 'application/json')
|
|
259
|
-
.expect(504);
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
});
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable max-nested-callbacks */
|
|
7
|
-
const index_1 = require("../../src/index");
|
|
8
|
-
const __1 = require("../../../..");
|
|
9
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
10
|
-
const fixtures_1 = require("./fixtures");
|
|
11
|
-
let adapterServer;
|
|
12
|
-
function sleep(ms) {
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
-
}
|
|
16
|
-
describe('execute', () => {
|
|
17
|
-
const id = '1';
|
|
18
|
-
let req;
|
|
19
|
-
jest.setTimeout(10000);
|
|
20
|
-
const successfulRequests = {
|
|
21
|
-
crypto: {
|
|
22
|
-
id,
|
|
23
|
-
data: {
|
|
24
|
-
base: 'ETH',
|
|
25
|
-
quote: 'USD',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
cryptoWithCoinid: {
|
|
29
|
-
id,
|
|
30
|
-
data: {
|
|
31
|
-
coinid: 'bitcoin',
|
|
32
|
-
quote: 'USD',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
cryptoWithOverride: {
|
|
36
|
-
id,
|
|
37
|
-
data: {
|
|
38
|
-
base: 'BTC',
|
|
39
|
-
quote: 'EUR',
|
|
40
|
-
overrides: {
|
|
41
|
-
coingecko: {
|
|
42
|
-
BTC: 'solana',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
coins: {
|
|
48
|
-
id,
|
|
49
|
-
endpoint: 'coins',
|
|
50
|
-
},
|
|
51
|
-
marketcap: {
|
|
52
|
-
id,
|
|
53
|
-
endpoint: 'marketcap',
|
|
54
|
-
data: {
|
|
55
|
-
base: 'ETH',
|
|
56
|
-
quote: 'USD',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
volume: {
|
|
60
|
-
id,
|
|
61
|
-
endpoint: 'volume',
|
|
62
|
-
data: {
|
|
63
|
-
base: 'ETH',
|
|
64
|
-
quote: 'USD',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
globalmarketcap: {
|
|
68
|
-
id,
|
|
69
|
-
endpoint: 'globalmarketcap',
|
|
70
|
-
data: {
|
|
71
|
-
market: 'ETH',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
dominance: {
|
|
75
|
-
id,
|
|
76
|
-
endpoint: 'dominance',
|
|
77
|
-
data: {
|
|
78
|
-
market: 'ETH',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
const errorRequests = {
|
|
83
|
-
cryptoWithBadSymbol: {
|
|
84
|
-
id,
|
|
85
|
-
data: {
|
|
86
|
-
base: 'ZWXK',
|
|
87
|
-
quote: 'USD',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
cryptoWithBadOverride: {
|
|
91
|
-
id,
|
|
92
|
-
data: {
|
|
93
|
-
base: 'LINK',
|
|
94
|
-
quote: 'USD',
|
|
95
|
-
overrides: {
|
|
96
|
-
coingecko: {
|
|
97
|
-
LINK: 'badtokenid',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
dominanceWithBadSymbol: {
|
|
103
|
-
id,
|
|
104
|
-
endpoint: 'dominance',
|
|
105
|
-
data: {
|
|
106
|
-
market: 'ZWXK',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
beforeAll(async () => {
|
|
111
|
-
try {
|
|
112
|
-
adapterServer = await (0, __1.expose)(index_1.adapter);
|
|
113
|
-
req = (0, supertest_1.default)('localhost:8080');
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
117
|
-
}
|
|
118
|
-
if (!adapterServer) {
|
|
119
|
-
throw new Error('Could not start server when running CoinGecko e2e tests');
|
|
120
|
-
}
|
|
121
|
-
(0, fixtures_1.createMocks)();
|
|
122
|
-
// Send inital requests to warm the cache
|
|
123
|
-
const pendingRequests = [];
|
|
124
|
-
for (const reqData of Object.values(successfulRequests)) {
|
|
125
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
126
|
-
}
|
|
127
|
-
for (const reqData of Object.values(errorRequests)) {
|
|
128
|
-
pendingRequests.push(req.post('/').send(reqData));
|
|
129
|
-
}
|
|
130
|
-
// Wait for all the pending requests to be complete
|
|
131
|
-
Promise.all(pendingRequests);
|
|
132
|
-
// Sleep while the cache is filled
|
|
133
|
-
await sleep(5000);
|
|
134
|
-
});
|
|
135
|
-
afterAll((done) => {
|
|
136
|
-
if (adapterServer) {
|
|
137
|
-
adapterServer.close(done());
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
describe('crypto api', () => {
|
|
141
|
-
it('should return success', async () => {
|
|
142
|
-
// Send inital request to warm cache
|
|
143
|
-
const response = await req
|
|
144
|
-
.post('/')
|
|
145
|
-
.send(successfulRequests.crypto)
|
|
146
|
-
.set('Accept', '*/*')
|
|
147
|
-
.set('Content-Type', 'application/json')
|
|
148
|
-
.expect(200);
|
|
149
|
-
expect(response.body.result).toMatchSnapshot();
|
|
150
|
-
});
|
|
151
|
-
it('should return success with coinid', async () => {
|
|
152
|
-
const response = await req
|
|
153
|
-
.post('/')
|
|
154
|
-
.send(successfulRequests.cryptoWithCoinid)
|
|
155
|
-
.set('Accept', '*/*')
|
|
156
|
-
.set('Content-Type', 'application/json')
|
|
157
|
-
.expect('Content-Type', /json/)
|
|
158
|
-
.expect(200);
|
|
159
|
-
expect(response.body.result).toMatchSnapshot();
|
|
160
|
-
});
|
|
161
|
-
it('should return error message for bad symbol', async () => {
|
|
162
|
-
await req
|
|
163
|
-
.post('/')
|
|
164
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
165
|
-
.set('Accept', '*/*')
|
|
166
|
-
.set('Content-Type', 'application/json')
|
|
167
|
-
.expect(504);
|
|
168
|
-
});
|
|
169
|
-
it('should return success with override', async () => {
|
|
170
|
-
const response = await req
|
|
171
|
-
.post('/')
|
|
172
|
-
.send(successfulRequests.cryptoWithOverride)
|
|
173
|
-
.set('Accept', '*/*')
|
|
174
|
-
.set('Content-Type', 'application/json')
|
|
175
|
-
.expect('Content-Type', /json/)
|
|
176
|
-
.expect(200);
|
|
177
|
-
expect(response.body.result).toMatchSnapshot();
|
|
178
|
-
});
|
|
179
|
-
it('should return 504 for bad override', async () => {
|
|
180
|
-
const response = await req
|
|
181
|
-
.post('/')
|
|
182
|
-
.send(errorRequests.cryptoWithBadOverride)
|
|
183
|
-
.set('Accept', '*/*')
|
|
184
|
-
.set('Content-Type', 'application/json')
|
|
185
|
-
.expect(504);
|
|
186
|
-
expect(typeof response.body.result === 'string');
|
|
187
|
-
});
|
|
188
|
-
it('should return 504 for bad symbol', async () => {
|
|
189
|
-
await req
|
|
190
|
-
.post('/')
|
|
191
|
-
.send(errorRequests.cryptoWithBadSymbol)
|
|
192
|
-
.set('Accept', '*/*')
|
|
193
|
-
.set('Content-Type', 'application/json')
|
|
194
|
-
.expect(504);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
describe('coins api', () => {
|
|
198
|
-
it('should return success', async () => {
|
|
199
|
-
await req
|
|
200
|
-
.post('/')
|
|
201
|
-
.send(successfulRequests.coins)
|
|
202
|
-
.set('Accept', '*/*')
|
|
203
|
-
.set('Content-Type', 'application/json')
|
|
204
|
-
.expect('Content-Type', /json/)
|
|
205
|
-
.expect(200);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
describe('volume api', () => {
|
|
209
|
-
it('should return success', async () => {
|
|
210
|
-
const response = await req
|
|
211
|
-
.post('/')
|
|
212
|
-
.send(successfulRequests.volume)
|
|
213
|
-
.set('Accept', '*/*')
|
|
214
|
-
.set('Content-Type', 'application/json')
|
|
215
|
-
.expect('Content-Type', /json/)
|
|
216
|
-
.expect(200);
|
|
217
|
-
expect(response.body.result).toMatchSnapshot();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
describe('marketcap api', () => {
|
|
221
|
-
it('should return success', async () => {
|
|
222
|
-
const response = await req
|
|
223
|
-
.post('/')
|
|
224
|
-
.send(successfulRequests.marketcap)
|
|
225
|
-
.set('Accept', '*/*')
|
|
226
|
-
.set('Content-Type', 'application/json')
|
|
227
|
-
.expect('Content-Type', /json/)
|
|
228
|
-
.expect(200);
|
|
229
|
-
expect(response.body.result).toMatchSnapshot();
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
describe('globalmarketcap api', () => {
|
|
233
|
-
it('should return success', async () => {
|
|
234
|
-
const response = await req
|
|
235
|
-
.post('/')
|
|
236
|
-
.send(successfulRequests.globalmarketcap)
|
|
237
|
-
.set('Accept', '*/*')
|
|
238
|
-
.set('Content-Type', 'application/json')
|
|
239
|
-
.expect('Content-Type', /json/)
|
|
240
|
-
.expect(200);
|
|
241
|
-
expect(response.body.result).toMatchSnapshot();
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
describe('dominance api', () => {
|
|
245
|
-
it('should return success', async () => {
|
|
246
|
-
const response = await req
|
|
247
|
-
.post('/')
|
|
248
|
-
.send(successfulRequests.dominance)
|
|
249
|
-
.set('Accept', '*/*')
|
|
250
|
-
.set('Content-Type', 'application/json')
|
|
251
|
-
.expect('Content-Type', /json/)
|
|
252
|
-
.expect(200);
|
|
253
|
-
expect(response.body.result).toMatchSnapshot();
|
|
254
|
-
});
|
|
255
|
-
it('should return 504 for bad symbol', async () => {
|
|
256
|
-
await req
|
|
257
|
-
.post('/')
|
|
258
|
-
.send(errorRequests.dominanceWithBadSymbol)
|
|
259
|
-
.set('Accept', '*/*')
|
|
260
|
-
.set('Content-Type', 'application/json')
|
|
261
|
-
.expect(504);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
});
|