@@ -366,147 +366,5 @@ describe('type tests', () => {
366366 } ) ,
367367 } )
368368 } )
369- // FIXME: This test is disabled because currently we can't make
370- // `TypedOnQueryStartedForQueryEndpoints` and `TypedOnQueryStartedForMutationEndpoints`.
371- // work together.
372- // test('TypedOnQueryStartedForQueryEndpoints and TypedOnQueryStartedForMutationEndpoints combined', () => {
373- // type Post = {
374- // id: number
375- // title: string
376- // userId: number
377- // }
378-
379- // type PostsApiResponse = {
380- // posts: Post[]
381- // total: number
382- // skip: number
383- // limit: number
384- // }
385-
386- // type QueryArgument = Pick<Post, 'id'> & Partial<Post>
387-
388- // type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
389-
390- // const baseApiSlice = createApi({
391- // baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com' }),
392- // reducerPath: 'postsApi',
393- // tagTypes: ['Posts'],
394- // endpoints: (builder) => ({
395- // getPosts: builder.query<PostsApiResponse, void>({
396- // query: () => `/posts`,
397- // }),
398-
399- // getPostById: builder.query<Post, number | undefined>({
400- // query: (postId) => `/posts/${postId}`,
401- // }),
402- // }),
403- // })
404-
405- // const updatePostOnFulfilled: TypedOnQueryStartedForQueryEndpoints<
406- // PostsApiResponse,
407- // QueryArgument,
408- // BaseQueryFunction,
409- // 'postsApi'
410- // > &
411- // TypedOnQueryStartedForMutationEndpoints<
412- // PostsApiResponse,
413- // QueryArgument,
414- // BaseQueryFunction,
415- // 'postsApi'
416- // > = async (queryArgument, lifeCycleApi) => {
417- // const {
418- // dispatch,
419- // extra,
420- // getCacheEntry,
421- // getState,
422- // queryFulfilled,
423- // requestId,
424- // } = lifeCycleApi
425-
426- // expectTypeOf(queryArgument).toEqualTypeOf<QueryArgument>()
427-
428- // expectTypeOf(dispatch).toEqualTypeOf<
429- // ThunkDispatch<any, any, UnknownAction>
430- // >()
431-
432- // expectTypeOf(extra).toBeUnknown()
433-
434- // expectTypeOf(getState).toEqualTypeOf<
435- // () => RootState<any, any, 'postsApi'>
436- // >()
437-
438- // expectTypeOf(requestId).toBeString()
439-
440- // expectTypeOf(getCacheEntry).toBeFunction()
441-
442- // expectTypeOf(lifeCycleApi).not.toHaveProperty('updateCachedData')
443-
444- // // This doesn't work for some reason
445- // // expectTypeOf(queryFulfilled).resolves.toEqualTypeOf<{
446- // // data: Post;
447- // // meta: FetchBaseQueryMeta | undefined;
448- // // } | {
449- // // data: PostsApiResponse;
450- // // meta: FetchBaseQueryMeta | undefined;
451- // // }>()
452-
453- // const result = await queryFulfilled
454-
455- // expectTypeOf(result).toMatchTypeOf<
456- // | {
457- // data: Post
458- // meta: FetchBaseQueryMeta | undefined
459- // }
460- // | {
461- // data: PostsApiResponse
462- // meta: FetchBaseQueryMeta | undefined
463- // }
464- // >()
465-
466- // const { posts } = result.data
467-
468- // dispatch(
469- // baseApiSlice.util.upsertQueryEntries(
470- // posts.map((post) => ({
471- // endpointName: 'getPostById',
472- // arg: post.id,
473- // value: post,
474- // })),
475- // ),
476- // )
477- // }
478-
479- // const extendedApiSlice = baseApiSlice.injectEndpoints({
480- // endpoints: (builder) => ({
481- // getPostsByUserId: builder.query<PostsApiResponse, QueryArgument>({
482- // query: (userId) => `/posts/user/${userId}`,
483-
484- // onQueryStarted: updatePostOnFulfilled,
485- // }),
486-
487- // addPost: builder.mutation<Post, Omit<QueryArgument, 'id'>>({
488- // query: (body) => ({
489- // url: `posts/add`,
490- // method: 'POST',
491- // body,
492- // }),
493-
494- // // FIXME: This results in a TS error which we need to fix.
495- // // onQueryStarted: updatePostOnFulfilled,
496- // }),
497-
498- // updatePost: builder.mutation<Post, QueryArgument>({
499- // query: ({ id, ...patch }) => ({
500- // url: `post/${id}`,
501- // method: 'PATCH',
502- // body: patch,
503- // }),
504-
505- // // FIXME: This results in a TS error which we need to fix.
506- // // onQueryStarted: updatePostOnFulfilled,
507- // }),
508- // }),
509- // })
510- // })
511369 } )
512370} )
0 commit comments