Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Jul 17, 2021
1 parent 1a055ef commit d87c248
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/toolkit/src/query/tests/buildHooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ describe('hooks tests', () => {

expectType<{
endpointName: string
originalArgs: { name: string }
track?: boolean
}>(res.arg)
expectType<string>(res.requestId)
Expand Down Expand Up @@ -1928,6 +1929,19 @@ describe('hooks with createApi defaults set', () => {
expect(getRenderCount()).toBe(5)
})

test('useMutation return value contains originalArgs', async () => {
const { result } = renderHook(api.endpoints.increment.useMutation, {
wrapper: storeRef.wrapper,
})

const firstRenderResult = result.current
expect(firstRenderResult[1].originalArgs).toBe(undefined)
firstRenderResult[0](5)
const secondRenderResult = result.current
expect(firstRenderResult[1].originalArgs).toBe(undefined)
expect(secondRenderResult[1].originalArgs).toBe(5)
})

it('useMutation with selectFromResult option has a type error if the result is not an object', async () => {
function Counter() {
const [increment] = api.endpoints.increment.useMutation({
Expand Down

0 comments on commit d87c248

Please sign in to comment.