Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Aug 23, 2023
1 parent 901545b commit 8b391da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ describe('createHeadlessMutation', () => {

expect(listeners.onSuccess).toHaveBeenCalledTimes(1);
expect(listeners.onSuccess).toHaveBeenCalledWith(
expect.objectContaining({ params: 42, result: 42 })
expect.objectContaining({ params: 42, result: 42, status: 'done' })
);

expect(listeners.onSkip).not.toHaveBeenCalled();
expect(listeners.onFailure).not.toHaveBeenCalled();

expect(listeners.onFinally).toHaveBeenCalledTimes(1);
expect(listeners.onFinally).toHaveBeenCalledWith(
expect.objectContaining({ params: 42, result: 42 })
expect.objectContaining({ params: 42, result: 42, status: 'done' })
);
});

Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/query/__tests__/create_headless_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ describe('core/createHeadlessQuery without contract', () => {
expect(scope.getState(query.$error)).toBeNull();
expect(listeners.onSuccess).toHaveBeenCalledTimes(1);
expect(listeners.onSuccess).toHaveBeenCalledWith(
expect.objectContaining({ params: 42, result: 42 })
expect.objectContaining({ params: 42, result: 42, status: 'done' })
);

expect(listeners.onSkip).not.toHaveBeenCalled();
expect(listeners.onFailure).not.toHaveBeenCalled();

expect(listeners.onFinally).toHaveBeenCalledTimes(1);
expect(listeners.onFinally).toHaveBeenCalledWith(
expect.objectContaining({ params: 42, result: 42 })
expect.objectContaining({ params: 42, result: 42, status: 'done' })
);
});

Expand Down Expand Up @@ -79,7 +79,11 @@ describe('core/createHeadlessQuery without contract', () => {

expect(listeners.onFinally).toHaveBeenCalledTimes(1);
expect(listeners.onFinally).toHaveBeenCalledWith(
expect.objectContaining({ params: 42, error: new Error('from mock') })
expect.objectContaining({
params: 42,
error: new Error('from mock'),
status: 'fail',
})
);
});

Expand Down

0 comments on commit 8b391da

Please sign in to comment.