mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-26 23:20:35 +08:00
In preparation for merging radicle-desktop into radicle-gui. It's a pure rename, so git can follow every file across the move.
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { beforeEach, expect, test } from "vitest";
|
|
|
|
import {
|
|
issueCountMismatch,
|
|
issueCounts,
|
|
resetIssueCounts,
|
|
updateIssueCounts,
|
|
} from "@app/lib/issueCounts.svelte";
|
|
|
|
const sidebar = { open: 3, closed: 2, all: 5 };
|
|
|
|
beforeEach(() => {
|
|
resetIssueCounts();
|
|
});
|
|
|
|
test.each([
|
|
["all", 5],
|
|
["open", 3],
|
|
["closed", 2],
|
|
] as const)(
|
|
"matches when the %s list has the sidebar's count",
|
|
(status, count) => {
|
|
updateIssueCounts(count, sidebar, status);
|
|
|
|
expect(issueCounts[status]).toEqual({ sidebar: count, total: count });
|
|
expect(issueCountMismatch(status)).toBe(false);
|
|
},
|
|
);
|
|
|
|
test("flags a list whose length differs from the sidebar", () => {
|
|
updateIssueCounts(4, sidebar, "open");
|
|
|
|
expect(issueCountMismatch("open")).toBe(true);
|
|
expect(issueCountMismatch("closed")).toBe(false);
|
|
});
|
|
|
|
test("reset clears every status", () => {
|
|
updateIssueCounts(4, sidebar, "open");
|
|
updateIssueCounts(1, sidebar, "closed");
|
|
resetIssueCounts();
|
|
|
|
expect(issueCounts).toEqual({
|
|
all: { sidebar: null, total: null },
|
|
open: { sidebar: null, total: null },
|
|
closed: { sidebar: null, total: null },
|
|
});
|
|
expect(issueCountMismatch("open")).toBe(false);
|
|
});
|