diff options
Diffstat (limited to 'tests/msw/handlers/thematics/thematic.handler.ts')
| -rw-r--r-- | tests/msw/handlers/thematics/thematic.handler.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/msw/handlers/thematics/thematic.handler.ts b/tests/msw/handlers/thematics/thematic.handler.ts new file mode 100644 index 0000000..1e7d129 --- /dev/null +++ b/tests/msw/handlers/thematics/thematic.handler.ts @@ -0,0 +1,23 @@ +import { type ExecutionResult, graphql as executeGraphql } from 'graphql'; +import { HttpResponse, graphql } from 'msw'; +import type { ThematicResponse } from '../../../../src/services/graphql'; +import { wpThematicsFixture } from '../../../fixtures'; +import { schema } from '../../schema'; + +export const thematicHandler = graphql.query< + ThematicResponse, + Record<'slug', string> +>('Thematic', async ({ query, variables }) => { + const { data, errors } = (await executeGraphql({ + schema, + source: query, + variableValues: variables, + rootValue: { + thematic: wpThematicsFixture.find( + (wpThematic) => wpThematic.slug === variables.slug + ), + }, + })) as ExecutionResult<ThematicResponse>; + + return HttpResponse.json({ data, errors }); +}); |
