@nucel/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -1
- package/src/lib/components/ui/CodeBlock.svelte +92 -0
- package/src/lib/components/ui/CopyButton.svelte +43 -0
- package/src/lib/components/ui/FilterBar.svelte +63 -0
- package/src/lib/components/ui/KanbanBoard.svelte +27 -0
- package/src/lib/components/ui/KanbanCard.svelte +43 -0
- package/src/lib/components/ui/KanbanColumn.svelte +52 -0
- package/src/lib/components/ui/MetricCard.svelte +79 -0
- package/src/lib/components/ui/Pagination.svelte +85 -0
- package/src/lib/components/ui/Timeline.svelte +85 -0
- package/src/lib/index.ts +25 -0
- package/src/lib/components/ui/Alert.test.ts +0 -206
- package/src/lib/components/ui/BranchPill.test.ts +0 -121
- package/src/lib/components/ui/CostDisplay.test.ts +0 -1115
- package/src/lib/components/ui/FormField.test.ts +0 -41
- package/src/lib/components/ui/PageHeader.test.ts +0 -72
- package/src/lib/components/ui/ProgressRing.test.ts +0 -239
- package/src/lib/components/ui/Section.test.ts +0 -44
- package/src/lib/components/ui/StatusBadge.test.ts +0 -150
- package/src/lib/components/ui/StatusPill.test.ts +0 -125
- package/src/lib/components/ui/table/Table.test.ts +0 -317
- package/src/lib/utils/cn.test.ts +0 -993
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { render, screen } from "@testing-library/svelte";
|
|
3
|
-
import Alert from "./Alert.svelte";
|
|
4
|
-
|
|
5
|
-
describe("Alert", () => {
|
|
6
|
-
it("renders without crashing", () => {
|
|
7
|
-
expect(() =>
|
|
8
|
-
render(Alert, { props: { children: (() => {}) as any } }),
|
|
9
|
-
).not.toThrow();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("renders a div with role=alert", () => {
|
|
13
|
-
const { container } = render(Alert, {
|
|
14
|
-
props: { children: (() => {}) as any },
|
|
15
|
-
});
|
|
16
|
-
expect(container.querySelector("[role=alert]")).not.toBeNull();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("applies base flex classes", () => {
|
|
20
|
-
const { container } = render(Alert, {
|
|
21
|
-
props: { children: (() => {}) as any },
|
|
22
|
-
});
|
|
23
|
-
const el = container.querySelector("[role=alert]");
|
|
24
|
-
expect(el!.className).toContain("flex");
|
|
25
|
-
expect(el!.className).toContain("items-start");
|
|
26
|
-
expect(el!.className).toContain("rounded-md");
|
|
27
|
-
expect(el!.className).toContain("border");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("applies default variant classes when no variant given", () => {
|
|
31
|
-
const { container } = render(Alert, {
|
|
32
|
-
props: { children: (() => {}) as any },
|
|
33
|
-
});
|
|
34
|
-
const el = container.querySelector("[role=alert]");
|
|
35
|
-
expect(el!.className).toContain("bg-muted/40");
|
|
36
|
-
expect(el!.className).toContain("text-foreground");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("applies destructive variant classes", () => {
|
|
40
|
-
const { container } = render(Alert, {
|
|
41
|
-
props: { variant: "destructive", children: (() => {}) as any },
|
|
42
|
-
});
|
|
43
|
-
const el = container.querySelector("[role=alert]");
|
|
44
|
-
expect(el!.className).toContain("text-destructive");
|
|
45
|
-
expect(el!.className).toContain("bg-destructive/10");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("applies success variant classes", () => {
|
|
49
|
-
const { container } = render(Alert, {
|
|
50
|
-
props: { variant: "success", children: (() => {}) as any },
|
|
51
|
-
});
|
|
52
|
-
const el = container.querySelector("[role=alert]");
|
|
53
|
-
expect(el!.className).toContain("bg-green-500/10");
|
|
54
|
-
expect(el!.className).toContain("text-green-600");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("applies warning variant classes", () => {
|
|
58
|
-
const { container } = render(Alert, {
|
|
59
|
-
props: { variant: "warning", children: (() => {}) as any },
|
|
60
|
-
});
|
|
61
|
-
const el = container.querySelector("[role=alert]");
|
|
62
|
-
expect(el!.className).toContain("bg-yellow-500/10");
|
|
63
|
-
expect(el!.className).toContain("text-yellow-500");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("applies info variant classes", () => {
|
|
67
|
-
const { container } = render(Alert, {
|
|
68
|
-
props: { variant: "info", children: (() => {}) as any },
|
|
69
|
-
});
|
|
70
|
-
const el = container.querySelector("[role=alert]");
|
|
71
|
-
expect(el!.className).toContain("bg-blue-500/10");
|
|
72
|
-
expect(el!.className).toContain("text-blue-400");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("renders title text when title prop is provided", () => {
|
|
76
|
-
render(Alert, {
|
|
77
|
-
props: { title: "Heads up!", children: (() => {}) as any },
|
|
78
|
-
});
|
|
79
|
-
expect(screen.getByText("Heads up!")).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("title element has font-semibold class", () => {
|
|
83
|
-
const { container } = render(Alert, {
|
|
84
|
-
props: { title: "My Title", children: (() => {}) as any },
|
|
85
|
-
});
|
|
86
|
-
const p = container.querySelector("p");
|
|
87
|
-
expect(p).not.toBeNull();
|
|
88
|
-
expect(p!.className).toContain("font-semibold");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("does not render a p element when title is not provided", () => {
|
|
92
|
-
const { container } = render(Alert, {
|
|
93
|
-
props: { children: (() => {}) as any },
|
|
94
|
-
});
|
|
95
|
-
expect(container.querySelector("p")).toBeNull();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("merges extra class prop with base classes", () => {
|
|
99
|
-
const { container } = render(Alert, {
|
|
100
|
-
props: { children: (() => {}) as any, class: "my-extra-class" },
|
|
101
|
-
});
|
|
102
|
-
const el = container.querySelector("[role=alert]");
|
|
103
|
-
expect(el!.className).toContain("my-extra-class");
|
|
104
|
-
expect(el!.className).toContain("rounded-md");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("does not render an svg/icon when icon prop is not provided", () => {
|
|
108
|
-
const { container } = render(Alert, {
|
|
109
|
-
props: { children: (() => {}) as any },
|
|
110
|
-
});
|
|
111
|
-
expect(container.querySelector("svg")).toBeNull();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("destructive variant has border-destructive/30 class", () => {
|
|
115
|
-
const { container } = render(Alert, {
|
|
116
|
-
props: { variant: "destructive", children: (() => {}) as any },
|
|
117
|
-
});
|
|
118
|
-
const el = container.querySelector("[role=alert]");
|
|
119
|
-
expect(el!.className).toContain("border-destructive/30");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("info variant has border-blue-500/30 class", () => {
|
|
123
|
-
const { container } = render(Alert, {
|
|
124
|
-
props: { variant: "info", children: (() => {}) as any },
|
|
125
|
-
});
|
|
126
|
-
const el = container.querySelector("[role=alert]");
|
|
127
|
-
expect(el!.className).toContain("border-blue-500/30");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("warning variant has border-yellow-500/30 class", () => {
|
|
131
|
-
const { container } = render(Alert, {
|
|
132
|
-
props: { variant: "warning", children: (() => {}) as any },
|
|
133
|
-
});
|
|
134
|
-
const el = container.querySelector("[role=alert]");
|
|
135
|
-
expect(el!.className).toContain("border-yellow-500/30");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("success variant has border-green-500/30 class", () => {
|
|
139
|
-
const { container } = render(Alert, {
|
|
140
|
-
props: { variant: "success", children: (() => {}) as any },
|
|
141
|
-
});
|
|
142
|
-
const el = container.querySelector("[role=alert]");
|
|
143
|
-
expect(el!.className).toContain("border-green-500/30");
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("default variant has border-border/60 class", () => {
|
|
147
|
-
const { container } = render(Alert, {
|
|
148
|
-
props: { children: (() => {}) as any },
|
|
149
|
-
});
|
|
150
|
-
const el = container.querySelector("[role=alert]");
|
|
151
|
-
expect(el!.className).toContain("border-border/60");
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("renders without crashing when neither children nor title given", () => {
|
|
155
|
-
expect(() => render(Alert, { props: {} })).not.toThrow();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("root element tag is div", () => {
|
|
159
|
-
const { container } = render(Alert, {
|
|
160
|
-
props: { children: (() => {}) as any },
|
|
161
|
-
});
|
|
162
|
-
const el = container.querySelector("[role=alert]");
|
|
163
|
-
expect(el!.tagName.toLowerCase()).toBe("div");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("root element has gap-3 class", () => {
|
|
167
|
-
const { container } = render(Alert, {
|
|
168
|
-
props: { children: (() => {}) as any },
|
|
169
|
-
});
|
|
170
|
-
const el = container.querySelector("[role=alert]");
|
|
171
|
-
expect(el!.className).toContain("gap-3");
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("root element has px-4 class", () => {
|
|
175
|
-
const { container } = render(Alert, {
|
|
176
|
-
props: { children: (() => {}) as any },
|
|
177
|
-
});
|
|
178
|
-
const el = container.querySelector("[role=alert]");
|
|
179
|
-
expect(el!.className).toContain("px-4");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("root element has py-3 class", () => {
|
|
183
|
-
const { container } = render(Alert, {
|
|
184
|
-
props: { children: (() => {}) as any },
|
|
185
|
-
});
|
|
186
|
-
const el = container.querySelector("[role=alert]");
|
|
187
|
-
expect(el!.className).toContain("py-3");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("root element has text-sm class", () => {
|
|
191
|
-
const { container } = render(Alert, {
|
|
192
|
-
props: { children: (() => {}) as any },
|
|
193
|
-
});
|
|
194
|
-
const el = container.querySelector("[role=alert]");
|
|
195
|
-
expect(el!.className).toContain("text-sm");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("does not lose variant classes when extra class is added", () => {
|
|
199
|
-
const { container } = render(Alert, {
|
|
200
|
-
props: { variant: "destructive", children: (() => {}) as any, class: "extra" },
|
|
201
|
-
});
|
|
202
|
-
const el = container.querySelector("[role=alert]");
|
|
203
|
-
expect(el!.className).toContain("text-destructive");
|
|
204
|
-
expect(el!.className).toContain("extra");
|
|
205
|
-
});
|
|
206
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { render, screen } from "@testing-library/svelte";
|
|
3
|
-
import BranchPill from "./BranchPill.svelte";
|
|
4
|
-
|
|
5
|
-
describe("BranchPill — rendering", () => {
|
|
6
|
-
it("renders the branch name", () => {
|
|
7
|
-
render(BranchPill, { props: { name: "main" } });
|
|
8
|
-
expect(screen.getByText("main")).toBeInTheDocument();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("renders a different branch name", () => {
|
|
12
|
-
render(BranchPill, { props: { name: "feature/my-feature" } });
|
|
13
|
-
expect(screen.getByText("feature/my-feature")).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("renders an svg element (git branch icon)", () => {
|
|
17
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
18
|
-
expect(container.querySelector("svg")).not.toBeNull();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("renders without crashing", () => {
|
|
22
|
-
expect(() => render(BranchPill, { props: { name: "develop" } })).not.toThrow();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("root element is a span", () => {
|
|
26
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
27
|
-
const el = container.firstElementChild;
|
|
28
|
-
expect(el?.tagName.toLowerCase()).toBe("span");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("BranchPill — classes", () => {
|
|
33
|
-
it("applies inline-flex class", () => {
|
|
34
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
35
|
-
const span = container.querySelector("span");
|
|
36
|
-
expect(span?.className).toContain("inline-flex");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("applies items-center class", () => {
|
|
40
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
41
|
-
const span = container.querySelector("span");
|
|
42
|
-
expect(span?.className).toContain("items-center");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("applies font-mono class", () => {
|
|
46
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
47
|
-
const span = container.querySelector("span");
|
|
48
|
-
expect(span?.className).toContain("font-mono");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("applies rounded-md class", () => {
|
|
52
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
53
|
-
const span = container.querySelector("span");
|
|
54
|
-
expect(span?.className).toContain("rounded-md");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("has border class", () => {
|
|
58
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
59
|
-
const span = container.querySelector("span");
|
|
60
|
-
expect(span?.className).toContain("border");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("size='sm' (default) applies text-[11px]", () => {
|
|
64
|
-
const { container } = render(BranchPill, { props: { name: "main" } });
|
|
65
|
-
const span = container.querySelector("span");
|
|
66
|
-
expect(span?.className).toContain("text-[11px]");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("size='sm' applies px-2", () => {
|
|
70
|
-
const { container } = render(BranchPill, { props: { name: "main", size: "sm" } });
|
|
71
|
-
const span = container.querySelector("span");
|
|
72
|
-
expect(span?.className).toContain("px-2");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("size='xs' applies text-[10px]", () => {
|
|
76
|
-
const { container } = render(BranchPill, { props: { name: "main", size: "xs" } });
|
|
77
|
-
const span = container.querySelector("span");
|
|
78
|
-
expect(span?.className).toContain("text-[10px]");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("size='xs' applies px-1.5", () => {
|
|
82
|
-
const { container } = render(BranchPill, { props: { name: "main", size: "xs" } });
|
|
83
|
-
const span = container.querySelector("span");
|
|
84
|
-
expect(span?.className).toContain("px-1.5");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("size='xs' does not apply text-[11px]", () => {
|
|
88
|
-
const { container } = render(BranchPill, { props: { name: "main", size: "xs" } });
|
|
89
|
-
const span = container.querySelector("span");
|
|
90
|
-
expect(span?.className).not.toContain("text-[11px]");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("size='sm' does not apply text-[10px]", () => {
|
|
94
|
-
const { container } = render(BranchPill, { props: { name: "main", size: "sm" } });
|
|
95
|
-
const span = container.querySelector("span");
|
|
96
|
-
expect(span?.className).not.toContain("text-[10px]");
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("BranchPill — edge cases", () => {
|
|
101
|
-
it("renders branch names with slashes", () => {
|
|
102
|
-
render(BranchPill, { props: { name: "feat/TICKET-123/add-auth" } });
|
|
103
|
-
expect(screen.getByText("feat/TICKET-123/add-auth")).toBeInTheDocument();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("renders very long branch names", () => {
|
|
107
|
-
const longName = "feature/very-long-branch-name-that-is-quite-descriptive";
|
|
108
|
-
render(BranchPill, { props: { name: longName } });
|
|
109
|
-
expect(screen.getByText(longName)).toBeInTheDocument();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("renders branch name with numbers", () => {
|
|
113
|
-
render(BranchPill, { props: { name: "release/1.2.3" } });
|
|
114
|
-
expect(screen.getByText("release/1.2.3")).toBeInTheDocument();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("renders both xs and sm without throwing", () => {
|
|
118
|
-
expect(() => render(BranchPill, { props: { name: "main", size: "xs" } })).not.toThrow();
|
|
119
|
-
expect(() => render(BranchPill, { props: { name: "main", size: "sm" } })).not.toThrow();
|
|
120
|
-
});
|
|
121
|
-
});
|