aboutsummaryrefslogtreecommitdiffstats
path: root/tests/msw/handlers/posts/recent-posts.handler.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-06 18:20:54 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-07 19:12:11 +0100
commitb8eb008dd5927fb736e56699637f5f8549965eae (patch)
tree648274babea3d3d09ed3e0f5f1fef013f94158fb /tests/msw/handlers/posts/recent-posts.handler.ts
parent802285872a2c57e7a5e130f32a2b45497d7687f1 (diff)
refactor(hooks): replace useGithubApi with useGithubRepoMeta
* use GraphQL API instead of REST (the inconvenient however is that we now need an authorization token...) * move fetcher in services * add tests * mock response using MSW
Diffstat (limited to 'tests/msw/handlers/posts/recent-posts.handler.ts')
-rw-r--r--tests/msw/handlers/posts/recent-posts.handler.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/msw/handlers/posts/recent-posts.handler.ts b/tests/msw/handlers/posts/recent-posts.handler.ts
index 34e0efb..eb89324 100644
--- a/tests/msw/handlers/posts/recent-posts.handler.ts
+++ b/tests/msw/handlers/posts/recent-posts.handler.ts
@@ -1,14 +1,15 @@
-import { type ExecutionResult, graphql as executeGraphql } from 'graphql';
-import { HttpResponse, graphql } from 'msw';
+import { type ExecutionResult, graphql } from 'graphql';
+import { HttpResponse } from 'msw';
import type {
FetchPostsListInput,
RecentPostsResponse,
} from '../../../../src/services/graphql';
import { wpPostsFixture } from '../../../fixtures';
import { getConnection } from '../../../utils/graphql';
+import { wordpressAPI } from '../../instances';
import { schema } from '../../schema';
-export const recentPostsHandler = graphql.query<
+export const recentPostsHandler = wordpressAPI.query<
RecentPostsResponse,
FetchPostsListInput
>('RecentPosts', async ({ query, variables }) => {
@@ -17,7 +18,7 @@ export const recentPostsHandler = graphql.query<
if (isError) return HttpResponse.json({ data: { posts: null } });
- const { data, errors } = (await executeGraphql({
+ const { data, errors } = (await graphql({
schema,
source: query,
variableValues: variables,