File tree 2 files changed +39
-0
lines changed
mocks/routes/rural-payments
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ export default [
29
29
}
30
30
}
31
31
} ,
32
+ {
33
+ id : 'not-found' ,
34
+ type : 'middleware' ,
35
+ options : {
36
+ middleware : ( req , res ) => {
37
+ return okOrNotFoundResponse ( res , { _data : null } )
38
+ }
39
+ }
40
+ } ,
32
41
{
33
42
id : 'error' ,
34
43
type : 'status' ,
Original file line number Diff line number Diff line change @@ -87,6 +87,36 @@ describe('Query.customer', () => {
87
87
} )
88
88
} )
89
89
90
+ it ( 'should handle person not found error' , async ( ) => {
91
+ await mockServer . server . mock . useRouteVariant (
92
+ 'rural-payments-person-get-by-id:not-found'
93
+ )
94
+
95
+ const result = await graphql ( {
96
+ source : `#graphql
97
+ query Customer($crn: ID!) {
98
+ customer(crn: $crn) {
99
+ info { dateOfBirth }
100
+ }
101
+ }
102
+ ` ,
103
+ variableValues : {
104
+ crn : '0866159801'
105
+ } ,
106
+ schema,
107
+ contextValue : fakeContext
108
+ } )
109
+
110
+ expect ( result ) . toEqual ( {
111
+ data : { customer : { info : null } } ,
112
+ errors : [ new GraphQLError ( 'Rural payments customer not found' ) ]
113
+ } )
114
+
115
+ await mockServer . server . mock . useRouteVariant (
116
+ 'rural-payments-person-get-by-id:default'
117
+ )
118
+ } )
119
+
90
120
it ( 'should handle error' , async ( ) => {
91
121
await mockServer . server . mock . useRouteVariant (
92
122
'rural-payments-person-get-by-id:error'
You can’t perform that action at this time.
0 commit comments