feat: added initial implementation
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import LocaleSwitch from "./LocaleSwitch";
|
||||
import i18n from "../i18n";
|
||||
|
||||
describe("LocaleSwitch", () => {
|
||||
beforeEach(async () => {
|
||||
localStorage.clear();
|
||||
await i18n.changeLanguage("en");
|
||||
});
|
||||
|
||||
it("persists locale and sets html lang/dir", async () => {
|
||||
render(<LocaleSwitch />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "العربية" }));
|
||||
await waitFor(() => {
|
||||
expect(document.documentElement.lang).toBe("ar-sa");
|
||||
});
|
||||
expect(document.documentElement.dir).toBe("rtl");
|
||||
expect(localStorage.getItem("locale")).toBe("ar-sa");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user