Move identity state labels into lib

This commit is contained in:
Rūdolfs Ošiņš
2026-10-01 18:20:25 +02:00
parent a1c3622f05
commit 9a023b625c
4 changed files with 72 additions and 35 deletions
+34
View File
@@ -0,0 +1,34 @@
import type { State } from "@bindings/identity/State";
import { expect, test } from "vitest";
import { stateCaption, stateIcon, stateLabel } from "@app/lib/identityState";
const sibling = "4b2d0a1e9f5c3b7a6d8e0f1a2b3c4d5e6f7a8b9c";
test.each<[State, string, string, string | undefined]>([
[{ status: "active" }, "hourglass", "Active", undefined],
[{ status: "accepted" }, "checkmark", "Accepted", undefined],
[
{ status: "rejected", reason: { type: "vote" } },
"close",
"Rejected",
"Rejected by delegate votes",
],
[
{ status: "rejected", reason: { type: "parent" } },
"close",
"Rejected",
"Rejected because its parent revision was rejected",
],
[
{ status: "rejected", reason: { type: "sibling", revision: sibling } },
"close",
"Rejected",
"Rejected because sibling 4b2d0a1 was accepted",
],
])("%j", (state, icon, label, caption) => {
expect(stateIcon(state)).toBe(icon);
expect(stateLabel(state)).toBe(label);
expect(stateCaption(state)).toBe(caption);
});