From 96fca14194d529031a38163dad017dc88df5749c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Wed, 12 Jun 2024 17:34:32 +0100 Subject: [PATCH] test(web): fix App tests --- web/src/App.test.jsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/web/src/App.test.jsx b/web/src/App.test.jsx index bf471ade8a..828a89fa39 100644 --- a/web/src/App.test.jsx +++ b/web/src/App.test.jsx @@ -42,6 +42,16 @@ jest.mock("~/context/product", () => ({ } })); +jest.mock("~/context/installer", () => ({ + ...jest.requireActual("~/context/installer"), + useInstallerClientStatus: () => { + return { + connected: true, + error: false + }; + } +})); + // Mock some components, // See https://www.chakshunyu.com/blog/how-to-mock-a-react-component-in-jest/#default-export jest.mock("~/components/questions/Questions", () => () =>
Questions Mock
); @@ -55,8 +65,12 @@ const getStatusFn = jest.fn(); const getPhaseFn = jest.fn(); // capture the latest subscription to the manager#onPhaseChange for triggering it manually -const onPhaseChangeFn = cb => { callbacks.onPhaseChange = cb }; -const onStatusChangeFn = cb => { callbacks.onStatusChange = cb }; +const onPhaseChangeFn = cb => { + callbacks.onPhaseChange = cb; +}; +const onStatusChangeFn = cb => { + callbacks.onStatusChange = cb; +}; const changePhaseTo = phase => act(() => callbacks.onPhaseChange(phase)); describe("App", () => { @@ -69,7 +83,7 @@ describe("App", () => { getStatus: getStatusFn, getPhase: getPhaseFn, onPhaseChange: onPhaseChangeFn, - onStatusChange: onStatusChangeFn, + onStatusChange: onStatusChangeFn }, l10n: { locales: jest.fn().mockResolvedValue([["en_us", "English", "United States"]]),