feat: complete advanced Sudoku workbench
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
BOARD_SCALE_STORAGE_KEY,
|
||||
colorMarkDescription,
|
||||
normalizeBoardScale,
|
||||
parseCandidateVerbosity,
|
||||
readStoredBoardScale,
|
||||
writeStoredBoardScale,
|
||||
} from "../../src/state/uiPreferences";
|
||||
|
||||
describe("UI accessibility preferences", () => {
|
||||
it("clamps and snaps persisted board scale safely", () => {
|
||||
expect(normalizeBoardScale(1.13)).toBe(1.25);
|
||||
expect(normalizeBoardScale(0.1)).toBe(0.75);
|
||||
expect(normalizeBoardScale(9)).toBe(2);
|
||||
expect(normalizeBoardScale("not a scale")).toBe(1);
|
||||
|
||||
const storage = { getItem: vi.fn(() => "1.49") };
|
||||
expect(readStoredBoardScale(storage)).toBe(1.5);
|
||||
expect(storage.getItem).toHaveBeenCalledWith(BOARD_SCALE_STORAGE_KEY);
|
||||
|
||||
const setItem = vi.fn();
|
||||
writeStoredBoardScale(1.74, { setItem });
|
||||
expect(setItem).toHaveBeenCalledWith(BOARD_SCALE_STORAGE_KEY, "1.75");
|
||||
});
|
||||
|
||||
it("survives unavailable storage and normalizes announcement settings", () => {
|
||||
expect(
|
||||
readStoredBoardScale({
|
||||
getItem: () => {
|
||||
throw new Error("blocked");
|
||||
},
|
||||
}),
|
||||
).toBe(1);
|
||||
expect(() =>
|
||||
writeStoredBoardScale(1.5, {
|
||||
setItem: () => {
|
||||
throw new Error("blocked");
|
||||
},
|
||||
}),
|
||||
).not.toThrow();
|
||||
expect(parseCandidateVerbosity("concise")).toBe("concise");
|
||||
expect(parseCandidateVerbosity("everything")).toBe("detailed");
|
||||
});
|
||||
|
||||
it("gives every colour mark a non-colour identifier", () => {
|
||||
expect(colorMarkDescription(1)).toBe("red, diagonal stripes");
|
||||
expect(colorMarkDescription(8)).toBe("pink, rings");
|
||||
expect(colorMarkDescription(99)).toBe("mark 99");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user