Skip to content

Commit

Permalink
test(web): fix App tests (#1323)
Browse files Browse the repository at this point in the history
Fix `App` component tests.
  • Loading branch information
imobachgs authored Jun 12, 2024
2 parents ef0796d + 96fca14 commit 0c0e409
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions web/src/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => () => <div>Questions Mock</div>);
Expand All @@ -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", () => {
Expand All @@ -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"]]),
Expand Down

0 comments on commit 0c0e409

Please sign in to comment.