From 29a1dec4de0aa7ba64ef068a83b1b8589fbc3ad0 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 28 Nov 2023 17:49:26 +0100 Subject: fix(services,types): make queries and types coherent for Topic * some nodes was missing in topicQuery * a node was mispelled in topicsListQuery * add tests for all topics fetchers --- tests/msw/handlers/topics/topic.handler.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/msw/handlers/topics/topic.handler.ts (limited to 'tests/msw/handlers/topics/topic.handler.ts') diff --git a/tests/msw/handlers/topics/topic.handler.ts b/tests/msw/handlers/topics/topic.handler.ts new file mode 100644 index 0000000..5df00ea --- /dev/null +++ b/tests/msw/handlers/topics/topic.handler.ts @@ -0,0 +1,21 @@ +import { type ExecutionResult, graphql as executeGraphql } from 'graphql'; +import { HttpResponse, graphql } from 'msw'; +import type { TopicResponse } from '../../../../src/services/graphql'; +import { wpTopicsFixture } from '../../../fixtures'; +import { schema } from '../../schema'; + +export const topicHandler = graphql.query< + TopicResponse, + Record<'slug', string> +>('Topic', async ({ query, variables }) => { + const { data, errors } = (await executeGraphql({ + schema, + source: query, + variableValues: variables, + rootValue: { + topic: wpTopicsFixture.find((wpTopic) => wpTopic.slug === variables.slug), + }, + })) as ExecutionResult; + + return HttpResponse.json({ data, errors }); +}); -- cgit v1.2.3