Skip to content

Commit

Permalink
[Discover] Add a test for fetchMore
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta committed Aug 10, 2023
1 parent 2a8fefa commit a57eafa
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,37 @@ describe('useDiscoverHistogram', () => {
});
expect(api.refetch).not.toHaveBeenCalled();
});

it('should skip the next refetch when fetching more', async () => {
const savedSearchFetch$ = new Subject<{
options: {
reset: boolean;
fetchMore: boolean;
};
searchSessionId: string;
}>();
const stateContainer = getStateContainer();
stateContainer.dataState.fetch$ = savedSearchFetch$;
const { hook } = await renderUseDiscoverHistogram({ stateContainer });
const api = createMockUnifiedHistogramApi();
act(() => {
hook.result.current.ref(api);
});
act(() => {
savedSearchFetch$.next({
options: { reset: false, fetchMore: true },
searchSessionId: '1234',
});
});
expect(api.refetch).not.toHaveBeenCalled();

act(() => {
savedSearchFetch$.next({
options: { reset: false, fetchMore: false },
searchSessionId: '1234',
});
});
expect(api.refetch).toHaveBeenCalled();
});
});
});

0 comments on commit a57eafa

Please sign in to comment.