fix(ui): harden theme toggle accessibility
This commit is contained in:
parent
cdb269e505
commit
b923ac8947
8 changed files with 75 additions and 9 deletions
|
|
@ -2,6 +2,7 @@ import { describe, expect, test } from "vitest";
|
|||
import {
|
||||
getNextUiTheme,
|
||||
isUiTheme,
|
||||
persistUiTheme,
|
||||
resolveInitialUiTheme,
|
||||
UI_THEME_STORAGE_KEY,
|
||||
} from "./theme";
|
||||
|
|
@ -25,6 +26,26 @@ describe("UI theme preference", () => {
|
|||
expect(resolveInitialUiTheme(storage)).toBe("dark");
|
||||
});
|
||||
|
||||
test("falls back when stored preferences cannot be read", () => {
|
||||
const storage = {
|
||||
getItem() {
|
||||
throw new Error("storage blocked");
|
||||
},
|
||||
};
|
||||
|
||||
expect(resolveInitialUiTheme(storage)).toBe("dark");
|
||||
});
|
||||
|
||||
test("ignores persistence failures", () => {
|
||||
const storage = {
|
||||
setItem() {
|
||||
throw new Error("quota exceeded");
|
||||
},
|
||||
};
|
||||
|
||||
expect(() => persistUiTheme("light", storage)).not.toThrow();
|
||||
});
|
||||
|
||||
test("detects and toggles supported themes", () => {
|
||||
expect(isUiTheme("light")).toBe(true);
|
||||
expect(isUiTheme("dark")).toBe(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue