1
1
const { assert } = require ( 'chai' )
2
- const { assertSuccess } = require ( '@chainlink/external-adapter' )
2
+ const { assertSuccess, assertError } = require ( '@chainlink/external-adapter' )
3
3
const { execute } = require ( '../adapter' )
4
4
5
5
describe ( 'execute' , ( ) => {
@@ -9,13 +9,16 @@ describe('execute', () => {
9
9
const requests = [
10
10
{
11
11
name : 'id not supplied' ,
12
- testData : { data : { } } ,
12
+ testData : { data : { field : 'totalTrust' } } ,
13
13
} ,
14
14
{
15
15
name : 'id is supplied' ,
16
- testData : { id : jobID , data : { } } ,
16
+ testData : { id : jobID , data : { field : 'totalTrust' } } ,
17
+ } ,
18
+ {
19
+ name : 'trust supply' ,
20
+ testData : { id : jobID , data : { field : 'totalToken' } } ,
17
21
} ,
18
- { name : 'empty body' , testData : { } } ,
19
22
]
20
23
21
24
requests . forEach ( ( req ) => {
@@ -29,4 +32,22 @@ describe('execute', () => {
29
32
} )
30
33
} )
31
34
} )
35
+
36
+ context ( 'error calls @integration' , ( ) => {
37
+ const requests = [
38
+ {
39
+ name : 'unknown field' ,
40
+ testData : { id : jobID , data : { field : 'not_real' } } ,
41
+ } ,
42
+ ]
43
+
44
+ requests . forEach ( ( req ) => {
45
+ it ( `${ req . name } ` , ( done ) => {
46
+ execute ( req . testData , ( statusCode , data ) => {
47
+ assertError ( { expected : 500 , actual : statusCode } , data , jobID )
48
+ done ( )
49
+ } )
50
+ } )
51
+ } )
52
+ } )
32
53
} )
0 commit comments