From 5e0730b08d92d1c5a9cf24fefcfc7d3823aac348 Mon Sep 17 00:00:00 2001 From: ivanThePleasant Date: Sun, 19 Feb 2023 22:13:25 +0200 Subject: [PATCH] Addition to hook test --- .../hooks/useLicenseLimits/tests/index.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/core/admin/ee/admin/hooks/useLicenseLimits/tests/index.test.js b/packages/core/admin/ee/admin/hooks/useLicenseLimits/tests/index.test.js index dd56af7524..d24f6042c9 100644 --- a/packages/core/admin/ee/admin/hooks/useLicenseLimits/tests/index.test.js +++ b/packages/core/admin/ee/admin/hooks/useLicenseLimits/tests/index.test.js @@ -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); + }); });