|
1 | 1 | 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'; |
2 | 5 |
|
3 |
| -test('root/currencyFormat error', async () => { |
| 6 | +test('root/currencyFormat data', async () => { |
4 | 7 | const { json, errors } = await gqlRequest({
|
5 | 8 | endpoint: 'zonos-customer-graph/currencyFormat',
|
6 | 9 | 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', |
13 | 19 | },
|
14 |
| - locations: [], |
15 |
| - message: |
16 |
| - 'javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized', |
17 |
| - path: ['currencyFormat'], |
18 |
| - }, |
19 |
| - ], |
| 20 | + } satisfies CurrencyFormatQuery, |
| 21 | + }, |
20 | 22 | }),
|
21 | 23 | variables: { input: 'AED' },
|
22 | 24 | });
|
| 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 | + }); |
23 | 56 | expect(json).toMatchInlineSnapshot(`null`);
|
24 | 57 | expect(errors).toMatchInlineSnapshot(`
|
25 | 58 | [
|
26 | 59 | {
|
27 |
| - "message": "{}", |
| 60 | + "message": "HTTP Status 401 - Full authentication is required to access this resource", |
28 | 61 | },
|
29 | 62 | ]
|
30 | 63 | `);
|
|
0 commit comments