Skip to content

Instantly share code, notes, and snippets.

@Dromediansk
Created June 13, 2020 14:21
Show Gist options
  • Save Dromediansk/7ed49cdf97aa45701d224f6d3182e5e3 to your computer and use it in GitHub Desktop.
Save Dromediansk/7ed49cdf97aa45701d224f6d3182e5e3 to your computer and use it in GitHub Desktop.
falsy.reference test in useFetch
it("should not fetch data if current reference is falsy", async () => {
const { result } = renderHook(() =>
useFetch(stubbedFetchUrl, { current: false }, [])
);
expect(global.fetch).not.toHaveBeenCalled();
expect(result.current).toStrictEqual({
loading: true,
data: [],
error: null,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment