Skip to content

Commit f8b50f0

Browse files
committed
refactor: update test for currencyFormat query
1 parent 477b273 commit f8b50f0

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed

src/rates/__tests__/currencyFormat.graphql.zonos-customer-graph.test.ts

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,63 @@
11
import { gqlRequest } from 'src/gqlRequest';
2+
import { mockedFetch } from 'src/testUtils/_mockedFetch';
3+
import { IResponseError } from 'src/types';
4+
import { CurrencyFormatQuery } from 'src/types/generated/graphql.zonos-customer-graph.types';
25

3-
test('root/currencyFormat error', async () => {
6+
test('root/currencyFormat data', async () => {
47
const { json, errors } = await gqlRequest({
58
endpoint: 'zonos-customer-graph/currencyFormat',
69
customFetch: async () =>
7-
JSON.stringify({
8-
data: null,
9-
errors: [
10-
{
11-
extensions: {
12-
errorType: 'INTERNAL',
10+
mockedFetch({
11+
response: {
12+
data: {
13+
currencyFormat: {
14+
decimalDelimiter: '.',
15+
thousandsDelimiter: ',',
16+
scale: 2,
17+
symbol: 'د.إ',
18+
symbolLocation: 'BEFORE',
1319
},
14-
locations: [],
15-
message:
16-
'javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized',
17-
path: ['currencyFormat'],
18-
},
19-
],
20+
} satisfies CurrencyFormatQuery,
21+
},
2022
}),
2123
variables: { input: 'AED' },
2224
});
25+
expect(json).toMatchInlineSnapshot(`
26+
{
27+
"currencyFormat": {
28+
"decimalDelimiter": ".",
29+
"scale": 2,
30+
"symbol": "د.إ",
31+
"symbolLocation": "BEFORE",
32+
"thousandsDelimiter": ",",
33+
},
34+
}
35+
`);
36+
expect(errors).toMatchInlineSnapshot(`[]`);
37+
});
38+
39+
test('root/rootCreate error', async () => {
40+
const { json, errors } = await gqlRequest({
41+
endpoint: 'zonos-customer-graph/rootCreate',
42+
customFetch: async () =>
43+
mockedFetch({
44+
ok: false,
45+
response: {
46+
data: null,
47+
errors: [
48+
{
49+
message:
50+
'HTTP Status 401 - Full authentication is required to access this resource',
51+
},
52+
] satisfies IResponseError[],
53+
},
54+
}),
55+
});
2356
expect(json).toMatchInlineSnapshot(`null`);
2457
expect(errors).toMatchInlineSnapshot(`
2558
[
2659
{
27-
"message": "{}",
60+
"message": "HTTP Status 401 - Full authentication is required to access this resource",
2861
},
2962
]
3063
`);

0 commit comments

Comments
 (0)