-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.test.ts
More file actions
97 lines (80 loc) · 2.59 KB
/
Copy pathformat.test.ts
File metadata and controls
97 lines (80 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { describe, it, expect } from "bun:test";
import { secondsToHuman, formatIssueLine } from "../src/format.ts";
describe("secondsToHuman", () => {
it("returns 0 for zero seconds", () => {
expect(secondsToHuman(0)).toBe("0");
});
it("converts 7200 seconds to 2h", () => {
expect(secondsToHuman(7200)).toBe("2h");
});
it("converts 5400 seconds to 1h 30m", () => {
expect(secondsToHuman(5400)).toBe("1h 30m");
});
it("converts 3600 seconds to 1h", () => {
expect(secondsToHuman(3600)).toBe("1h");
});
it("converts 1800 seconds to 30m", () => {
expect(secondsToHuman(1800)).toBe("30m");
});
it("converts 60 seconds to 1m", () => {
expect(secondsToHuman(60)).toBe("1m");
});
it("converts 1 working day (8h = 28800s) to 1d", () => {
expect(secondsToHuman(28800)).toBe("1d");
});
it("converts 1 working week (5d x 8h = 144000s) to 1w", () => {
expect(secondsToHuman(144000)).toBe("1w");
});
it("handles hours and minutes together", () => {
expect(secondsToHuman(9000)).toBe("2h 30m");
});
it("handles days and hours together", () => {
expect(secondsToHuman(32400)).toBe("1d 1h");
});
});
describe("formatIssueLine", () => {
// Since format output depends on TTY detection (colors), we check structure
// by checking that key pieces appear in the output string
it("includes iid and title", () => {
const line = formatIssueLine({ iid: 42, state: "opened", title: "Fix the bug" });
expect(line).toContain("42");
expect(line).toContain("Fix the bug");
});
it("includes state", () => {
const line = formatIssueLine({ iid: 1, state: "closed", title: "Done" });
expect(line).toContain("closed");
});
it("includes labels when provided", () => {
const line = formatIssueLine({
iid: 5,
state: "opened",
title: "T",
labels: ["bug", "v2"],
});
expect(line).toContain("bug");
expect(line).toContain("v2");
});
it("includes assignee when provided", () => {
const line = formatIssueLine({
iid: 7,
state: "opened",
title: "T",
assignee: "alice",
});
expect(line).toContain("alice");
});
it("omits labels section when labels array is empty", () => {
const line = formatIssueLine({
iid: 3,
state: "opened",
title: "No Labels",
labels: [],
});
// Should not contain parentheses for empty labels
expect(line).not.toContain("()");
});
it("omits assignee when not provided", () => {
const line = formatIssueLine({ iid: 8, state: "opened", title: "No Assignee" });
expect(line).not.toContain("@");
});
});