Skip to content

Commit bdbae61

Browse files
committed
jest
1 parent 94a3587 commit bdbae61

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

site/src/pages/UserSettingsPage/AppearancePage/AppearancePage.test.tsx

+25-4
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,53 @@ describe("appearance page", () => {
1212
jest.spyOn(API, "updateAppearanceSettings").mockResolvedValueOnce({
1313
...MockUser,
1414
theme_preference: "dark",
15-
terminal_font: "",
15+
terminal_font: "fira-code",
1616
});
1717

1818
const dark = await screen.findByText("Dark");
1919
await userEvent.click(dark);
2020

2121
// Check if the API was called correctly
22-
expect(API.updateAppearanceSettings).toBeCalledTimes(0);
22+
expect(API.updateAppearanceSettings).toHaveBeenCalledTimes(0);
2323
});
2424

2525
it("changes theme to light", async () => {
2626
renderWithAuth(<AppearancePage />);
2727

2828
jest.spyOn(API, "updateAppearanceSettings").mockResolvedValueOnce({
2929
...MockUser,
30+
terminal_font: "ibm-plex-mono",
3031
theme_preference: "light",
31-
terminal_font: "",
3232
});
3333

3434
const light = await screen.findByText("Light");
3535
await userEvent.click(light);
3636

3737
// Check if the API was called correctly
38-
expect(API.updateAppearanceSettings).toBeCalledTimes(1);
38+
expect(API.updateAppearanceSettings).toHaveBeenCalledTimes(1);
3939
expect(API.updateAppearanceSettings).toHaveBeenCalledWith({
40+
terminal_font: "ibm-plex-mono",
4041
theme_preference: "light",
4142
});
4243
});
44+
45+
it("changes font to fira code", async () => {
46+
renderWithAuth(<AppearancePage />);
47+
48+
jest.spyOn(API, "updateAppearanceSettings").mockResolvedValueOnce({
49+
...MockUser,
50+
terminal_font: "fira-code",
51+
theme_preference: "dark",
52+
});
53+
54+
const ibmPlex = await screen.findByText("Fira Code");
55+
await userEvent.click(ibmPlex);
56+
57+
// Check if the API was called correctly
58+
expect(API.updateAppearanceSettings).toHaveBeenCalledTimes(1);
59+
expect(API.updateAppearanceSettings).toHaveBeenCalledWith({
60+
terminal_font: "fira-code",
61+
theme_preference: "dark",
62+
});
63+
});
4364
});

0 commit comments

Comments
 (0)