Skip to content

Commit b9910e3

Browse files
committed
cover person not found error
1 parent 59bc96c commit b9910e3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

mocks/routes/rural-payments/person.js

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ export default [
2929
}
3030
}
3131
},
32+
{
33+
id: 'not-found',
34+
type: 'middleware',
35+
options: {
36+
middleware: (req, res) => {
37+
return okOrNotFoundResponse(res, { _data: null })
38+
}
39+
}
40+
},
3241
{
3342
id: 'error',
3443
type: 'status',

test/integration/graphql/customer.test.js

+30
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,36 @@ describe('Query.customer', () => {
8787
})
8888
})
8989

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+
90120
it('should handle error', async () => {
91121
await mockServer.server.mock.useRouteVariant(
92122
'rural-payments-person-get-by-id:error'

0 commit comments

Comments
 (0)