-
Notifications
You must be signed in to change notification settings - Fork 308
/
getPayout.test.ts
39 lines (35 loc) · 1.28 KB
/
getPayout.test.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
import { AdapterError, Requester } from '@chainlink/ea-bootstrap'
import { assertError } from '@chainlink/ea-test-helpers'
import { AdapterRequest } from '@chainlink/ea-bootstrap'
import { makeExecute } from '../../src/adapter'
import { TInputParameters } from '../../src/endpoint'
describe('execute', () => {
const jobID = '1'
const execute = makeExecute()
process.env.CLIENT_ID = process.env.CLIENT_ID ?? 'test_client_id'
process.env.CLIENT_SECRET = process.env.CLIENT_SECRET ?? 'test_client_secret'
describe('validation error', () => {
const requests = [
{ name: 'empty body', testData: {} },
{ name: 'empty data', testData: { data: {} } },
{
name: 'payout_id not supplied',
testData: { id: jobID, data: { type: 'BATCH' } },
},
{
name: 'invalid type supplied',
testData: { id: jobID, data: { payout_id: 'abc', type: 'MIX' } },
},
]
requests.forEach((req) => {
it(`${req.name}`, async () => {
try {
await execute(req.testData as AdapterRequest<TInputParameters>, {})
} catch (error) {
const errorResp = Requester.errored(jobID, error as AdapterError)
assertError({ expected: 400, actual: errorResp.statusCode }, errorResp, jobID)
}
})
})
})
})