Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix render and dispose checks in useQueryLoader tests #4737

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,11 @@ it('releases and cancels all queries if a the callback is called, the component
* useQueryLoader */
queryLoaderCallback({});
});
const secondDispose = dispose;
expect(renderCount).toEqual(3);
expect(renderCount).toEqual(2);
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(firstDispose).toHaveBeenCalledTimes(1);
expect(secondDispose).not.toHaveBeenCalled();
expect(firstDispose).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
expect(secondDispose).toHaveBeenCalledTimes(1);
expect(firstDispose).toHaveBeenCalledTimes(1);
});

it('releases and cancels all queries if the component suspends, another query is loaded and then the component unmounts', () => {
Expand Down Expand Up @@ -728,7 +726,7 @@ it('releases and cancels all queries if the component suspends, another query is
queryLoaderCallback({});
});

expect(renderCount).toEqual(2);
expect(renderCount).toEqual(1);
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(dispose).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,11 @@ describe('useQueryLoader', () => {
* useQueryLoader */
queryLoaderCallback({});
});
const secondDispose = releaseQuery;
expect(renderCount).toEqual(2);
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(firstDispose).toHaveBeenCalledTimes(1);
expect(secondDispose).not.toHaveBeenCalled();
expect(firstDispose).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
expect(secondDispose).toHaveBeenCalledTimes(1);
expect(firstDispose).toHaveBeenCalledTimes(1);
});

it('releases all queries if the component suspends, another query is loaded and then the component unmounts', () => {
Expand Down Expand Up @@ -778,7 +776,7 @@ describe('useQueryLoader', () => {
queryLoaderCallback({});
});

expect(renderCount).toEqual(2);
expect(renderCount).toEqual(1);
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(releaseQuery).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
Expand Down
Loading