mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-12 22:29:53 -06:00
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { describe, test } from "vitest";
|
|
import {
|
|
assertDecodesToDefault,
|
|
assertRoundTrips,
|
|
} from "~/modules/persisted-state/persisted-state-test-utils";
|
|
import {
|
|
devToolbarPersisted,
|
|
scenarioFilterPersisted,
|
|
scenarioLogInPersisted,
|
|
scenarioParamsPersisted,
|
|
simulateAdsPersisted,
|
|
} from "./dev-tools-persisted";
|
|
|
|
describe("devToolbarPersisted", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(devToolbarPersisted, [
|
|
{ isMinimized: false },
|
|
{ isMinimized: true },
|
|
]);
|
|
});
|
|
|
|
test("malformed values decode to the default", () => {
|
|
assertDecodesToDefault(devToolbarPersisted, [
|
|
"not json",
|
|
'{"isOpen":true,"tab":"scenarios"}',
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("scenarioLogInPersisted", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(scenarioLogInPersisted, [true, false]);
|
|
});
|
|
|
|
test("malformed values decode to the default", () => {
|
|
assertDecodesToDefault(scenarioLogInPersisted, ["yes", "1"]);
|
|
});
|
|
});
|
|
|
|
describe("scenarioFilterPersisted", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(scenarioFilterPersisted, ["", "lobbies", " lobby open "]);
|
|
});
|
|
|
|
test("malformed values decode to the default", () => {
|
|
assertDecodesToDefault(scenarioFilterPersisted, ["12", "null"]);
|
|
});
|
|
});
|
|
|
|
describe("scenarioParamsPersisted", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(scenarioParamsPersisted, [
|
|
{},
|
|
{ teams: 16, format: "swiss" },
|
|
]);
|
|
});
|
|
|
|
test("malformed values decode to the default", () => {
|
|
assertDecodesToDefault(scenarioParamsPersisted, ["[]", '{"teams":true}']);
|
|
});
|
|
});
|
|
|
|
describe("simulateAdsPersisted", () => {
|
|
test("round-trips", () => {
|
|
assertRoundTrips(simulateAdsPersisted, [true, false]);
|
|
});
|
|
|
|
test("malformed values decode to the default", () => {
|
|
assertDecodesToDefault(simulateAdsPersisted, ["yes", "1"]);
|
|
});
|
|
});
|