From 5fd244ce24d6e8832d23574c47c72b7e70a862be Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 5 Jul 2024 15:59:55 +0100 Subject: [PATCH] tests --- .../user/PreferencesUserSettingsTab-test.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx b/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx index ee0408528b..4541720159 100644 --- a/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx +++ b/test/components/views/settings/tabs/user/PreferencesUserSettingsTab-test.tsx @@ -55,6 +55,28 @@ describe("PreferencesUserSettingsTab", () => { expect(reloadStub).toHaveBeenCalled(); }); + it("should not show spell check setting if unsupported", async () => { + PlatformPeg.get()!.supportsSpellCheckSettings = jest.fn().mockReturnValue(false); + + renderTab(); + expect(screen.queryByRole("switch", { name: "Allow spell check" })).not.toBeInTheDocument(); + }); + + it("should enable spell check", async () => { + const spellCheckEnableFn = jest.fn(); + PlatformPeg.get()!.supportsSpellCheckSettings = jest.fn().mockReturnValue(true); + PlatformPeg.get()!.getSpellCheckEnabled = jest.fn().mockReturnValue(false); + PlatformPeg.get()!.setSpellCheckEnabled = spellCheckEnableFn; + + renderTab(); + const toggle = await screen.findByRole("switch", { name: "Allow spell check" }); + expect(toggle).toHaveAttribute("aria-checked", "false"); + + await userEvent.click(toggle); + + expect(spellCheckEnableFn).toHaveBeenCalledWith(true); + }); + describe("send read receipts", () => { beforeEach(() => { stubClient();