feat: allow dashboard section reordering
This commit is contained in:
33
tests/dashboard-sections.test.ts
Normal file
33
tests/dashboard-sections.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_DASHBOARD_SECTION_ORDER,
|
||||
normalizeDashboardSectionOrder,
|
||||
normalizeDashboardSectionVisibility,
|
||||
} from "@/lib/dashboard-sections";
|
||||
|
||||
describe("dashboard sections", () => {
|
||||
it("keeps stored section order and appends missing defaults", () => {
|
||||
expect(normalizeDashboardSectionOrder(["forecast", "weatherBrief", "unknown"])).toEqual([
|
||||
"forecast",
|
||||
"weatherBrief",
|
||||
"warnings",
|
||||
"favorites",
|
||||
"featuredStations",
|
||||
]);
|
||||
});
|
||||
|
||||
it("falls back to the default order for invalid values", () => {
|
||||
expect(normalizeDashboardSectionOrder(null)).toEqual(DEFAULT_DASHBOARD_SECTION_ORDER);
|
||||
});
|
||||
|
||||
it("normalizes visibility for older stored preferences", () => {
|
||||
expect(normalizeDashboardSectionVisibility({ weatherBrief: false })).toEqual({
|
||||
warnings: true,
|
||||
weatherBrief: false,
|
||||
forecast: true,
|
||||
favorites: true,
|
||||
featuredStations: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user