Addition to hook test

This commit is contained in:
ivanThePleasant 2023-02-19 22:13:25 +02:00
parent a39f8fad2b
commit 5e0730b08d

View File

@ -27,4 +27,17 @@ describe('useLicenseLimits', () => {
expect(useQuery).toHaveBeenCalledWith(['ee', 'license-limit-info'], expect.any(Function));
expect(result.current.license.data).toEqual(data.data);
});
it('data should be undefined if there is an API error', async () => {
// const data = { data: { id: 1, name: 'Test License' } };
useQuery.mockReturnValue({
isError: true,
});
const { result } = renderHook(() => useLicenseLimits());
expect(useFetchClient).toHaveBeenCalled();
expect(useQuery).toHaveBeenCalledWith(['ee', 'license-limit-info'], expect.any(Function));
expect(result.current.license.data).toEqual(undefined);
});
});