source: node_modules/@reduxjs/toolkit/src/query/tests/cacheLifecycle.test-d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 936 bytes
RevLine 
[a762898]1import type { FetchBaseQueryMeta } from '@reduxjs/toolkit/query'
2import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
3
4const api = createApi({
5 baseQuery: fetchBaseQuery({ baseUrl: 'https://example.com' }),
6 endpoints: () => ({}),
7})
8
9describe('type tests', () => {
10 test(`mutation: await cacheDataLoaded, await cacheEntryRemoved (success)`, () => {
11 const extended = api.injectEndpoints({
12 overrideExisting: true,
13 endpoints: (build) => ({
14 injected: build.mutation<number, string>({
15 query: () => '/success',
16 async onCacheEntryAdded(
17 arg,
18 { dispatch, getState, cacheEntryRemoved, cacheDataLoaded },
19 ) {
20 const firstValue = await cacheDataLoaded
21
22 expectTypeOf(firstValue).toMatchTypeOf<{
23 data: number
24 meta?: FetchBaseQueryMeta
25 }>()
26 },
27 }),
28 }),
29 })
30 })
31})
Note: See TracBrowser for help on using the repository browser.