Skip to content

Commit

Permalink
web: Fix tests
Browse files Browse the repository at this point in the history
- Add missing mock.
  • Loading branch information
joseivanlopez committed Apr 8, 2024
1 parent 2c76047 commit 816ae4d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion web/src/components/core/Page.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) [2023] SUSE LLC
* Copyright (c) [2023-2024] SUSE LLC
*
* All Rights Reserved.
*
Expand All @@ -23,12 +23,35 @@ import React from "react";
import { screen, within } from "@testing-library/react";
import { installerRender, plainRender, mockNavigateFn } from "~/test-utils";
import { Page } from "~/components/core";
import { createClient } from "~/client";

jest.mock("~/client");

const l10nClientMock = {
getUILocale: jest.fn().mockResolvedValue("en_US"),
keymaps: jest.fn().mockResolvedValue([]),
getKeymap: jest.fn().mockResolvedValue(undefined),
timezones: jest.fn().mockResolvedValue([]),
getTimezone: jest.fn().mockResolvedValue(undefined),
onLocalesChange: jest.fn(),
onKeymapChange: jest.fn(),
onTimezoneChange: jest.fn()
};

describe("Page", () => {
beforeAll(() => {
jest.spyOn(console, "error").mockImplementation();
});

beforeEach(() => {
// if defined outside, the mock is cleared automatically
createClient.mockImplementation(() => {
return {
l10n: l10nClientMock
};
});
});

afterAll(() => {
console.error.mockRestore();
});
Expand Down

0 comments on commit 816ae4d

Please sign in to comment.