Skip to content

Commit 4aa846b

Browse files
committed
Update potentially mismatched legacy code in tests
1 parent b79043b commit 4aa846b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/query/tests/createApi.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,10 @@ describe('query endpoint lifecycles - onStart, onSuccess, onError', () => {
597597
}),
598598
query: build.query<SuccessResponse, void>({
599599
query: () => '/success',
600-
async onQuery(_, api) {
600+
async onQueryStarted(_, api) {
601601
api.dispatch(setCount(0))
602602
try {
603-
await api.resultPromise
603+
await api.queryFulfilled
604604
api.dispatch(setCount(1))
605605
} catch {
606606
api.dispatch(setCount(-1))
@@ -609,10 +609,10 @@ describe('query endpoint lifecycles - onStart, onSuccess, onError', () => {
609609
}),
610610
mutation: build.mutation<SuccessResponse, void>({
611611
query: () => ({ url: '/success', method: 'POST' }),
612-
async onQuery(_, api) {
612+
async onQueryStarted(_, api) {
613613
api.dispatch(setCount(0))
614614
try {
615-
await api.resultPromise
615+
await api.queryFulfilled
616616
api.dispatch(setCount(1))
617617
} catch {
618618
api.dispatch(setCount(-1))

src/query/tests/optimisticUpdates.test.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ describe('basic lifecycle', () => {
5656
endpoints: (build) => ({
5757
test: build.mutation({
5858
query: (x) => x,
59-
async onQuery(arg, api) {
59+
async onQueryStarted(arg, api) {
6060
onStart(arg)
6161
try {
62-
const result = await api.resultPromise
62+
const result = await api.queryFulfilled
6363
onSuccess(result)
6464
} catch (e) {
6565
onError(e)
@@ -96,7 +96,7 @@ describe('basic lifecycle', () => {
9696
expect(onSuccess).not.toHaveBeenCalled()
9797
await act(() => waitMs(5))
9898
expect(onError).not.toHaveBeenCalled()
99-
expect(onSuccess).toHaveBeenCalledWith('success')
99+
expect(onSuccess).toHaveBeenCalledWith({ data: 'success', meta: 'meta' })
100100
})
101101

102102
test('error', async () => {
@@ -118,7 +118,10 @@ describe('basic lifecycle', () => {
118118
expect(onError).not.toHaveBeenCalled()
119119
expect(onSuccess).not.toHaveBeenCalled()
120120
await act(() => waitMs(5))
121-
expect(onError).toHaveBeenCalledWith({ message: 'error' })
121+
expect(onError).toHaveBeenCalledWith({
122+
error: { message: 'error' },
123+
isUnhandledError: true,
124+
})
122125
expect(onSuccess).not.toHaveBeenCalled()
123126
})
124127
})
@@ -166,7 +169,7 @@ describe('updateQueryData', () => {
166169

167170
act(() => {
168171
storeRef.store.dispatch(
169-
api.util.patchQueryData('post', '3', returnValue.inversePatches)
172+
api.util.patchQueryResult('post', '3', returnValue.inversePatches)
170173
)
171174
})
172175

0 commit comments

Comments
 (0)