Files
kandev/apps/web/lib/utils/file-change-status.test.ts
T
José Almeida e067e7a1f6 feat(web): show file statuses in review (#1683)
* feat(web): show file statuses in review

* fix(web): address review status feedback

* fix(web): deduplicate review sources

* fix(web): align review progress identities

* fix(web): guard review status labels

* fix(web): enforce file status exhaustiveness

* perf(web): index review progress sources

* fix(web): preserve files during status hydration

* fix(web): align multi-repo review progress
2026-07-15 12:54:43 +01:00

43 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
fileChangeStatusLabel,
normalizeFileChangeStatus,
type FileChangeStatus,
} from "./file-change-status";
describe("normalizeFileChangeStatus", () => {
it.each<FileChangeStatus>(["added", "modified", "deleted", "untracked", "renamed"])(
"preserves local status %s",
(status) => {
expect(normalizeFileChangeStatus(status)).toBe(status);
},
);
it("maps GitHub removed status to deleted", () => {
expect(normalizeFileChangeStatus("removed")).toBe("deleted");
});
it.each([undefined, "copied", "changed", "unexpected"])(
"falls back to modified for %s",
(status) => {
expect(normalizeFileChangeStatus(status)).toBe("modified");
},
);
});
describe("fileChangeStatusLabel", () => {
it.each<[FileChangeStatus, string]>([
["added", "Added"],
["untracked", "Untracked"],
["modified", "Modified"],
["deleted", "Deleted"],
["renamed", "Moved"],
])("labels %s as %s", (status, label) => {
expect(fileChangeStatusLabel(status)).toBe(label);
});
it("includes previous path for moved files", () => {
expect(fileChangeStatusLabel("renamed", "src/old-name.ts")).toBe("Moved from src/old-name.ts");
});
});