Skip to content

Commit 0476e8b

Browse files
committed
test: Fix status label test groups
1 parent bbaffca commit 0476e8b

1 file changed

Lines changed: 106 additions & 119 deletions

File tree

src/test/badges/status-label/status-label.test.ts

Lines changed: 106 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -36,163 +36,150 @@ describe("zeta-status-label", () => {
3636
});
3737
});
3838
describe("Content", () => {
39-
describe("status prop", () => {
40-
it("sets default status to neutral", () => {
41-
expect(subject.status).to.equal("neutral");
42-
});
39+
it("sets default status to neutral", () => {
40+
expect(subject.status).to.equal("neutral");
41+
});
4342

44-
["info", "positive", "warning", "negative", "neutral"].forEach(status => {
45-
it(`can set status to ${status}`, async () => {
46-
subject.status = status as any;
47-
await elementUpdated(subject);
48-
expect(subject.status).to.equal(status);
49-
expect(subject.getAttribute("status")).to.equal(status);
50-
});
43+
["info", "positive", "warning", "negative", "neutral"].forEach(status => {
44+
it(`can set status to ${status}`, async () => {
45+
subject.status = status as any;
46+
await elementUpdated(subject);
47+
expect(subject.status).to.equal(status);
48+
expect(subject.getAttribute("status")).to.equal(status);
5149
});
5250
});
5351

54-
describe("label prop", () => {
55-
it("renders label text when label prop is set", async () => {
56-
subject.label = "Test Label";
57-
await elementUpdated(subject);
52+
it("renders label text when label prop is set", async () => {
53+
subject.label = "Test Label";
54+
await elementUpdated(subject);
5855

59-
const textPart = subject.shadowRoot?.querySelector("[part='text']");
60-
expect(textPart?.textContent).to.equal("Test Label");
61-
});
56+
const textPart = subject.shadowRoot?.querySelector("[part='text']");
57+
expect(textPart?.textContent).to.equal("Test Label");
58+
});
6259

63-
it("should be undefined by default", () => {
64-
expect(subject.label).to.be.undefined;
65-
});
60+
it("should be undefined by default", () => {
61+
expect(subject.label).to.be.undefined;
62+
});
6663

67-
it("overrides slot content when label prop is set", async () => {
68-
const componentWithSlot = await createComponent(`<zeta-status-label>Slot Text</zeta-status-label>`);
69-
expect(componentWithSlot.textContent).to.include("Slot Text");
64+
it("overrides slot content when label prop is set", async () => {
65+
const componentWithSlot = await createComponent(`<zeta-status-label>Slot Text</zeta-status-label>`);
66+
expect(componentWithSlot.textContent).to.include("Slot Text");
7067

71-
componentWithSlot.label = "Label Text";
72-
await elementUpdated(componentWithSlot);
73-
const textPart = componentWithSlot.shadowRoot?.querySelector("[part='text']");
74-
expect(textPart?.textContent).to.equal("Label Text");
75-
});
68+
componentWithSlot.label = "Label Text";
69+
await elementUpdated(componentWithSlot);
70+
const textPart = componentWithSlot.shadowRoot?.querySelector("[part='text']");
71+
expect(textPart?.textContent).to.equal("Label Text");
7672
});
7773

78-
describe("icon prop", () => {
79-
it("should be undefined by default", () => {
80-
expect(subject.icon).to.be.undefined;
81-
});
74+
it("should be undefined by default", () => {
75+
expect(subject.icon).to.be.undefined;
76+
});
8277

83-
it("renders a zeta-icon when icon prop is set", async () => {
84-
subject.icon = "star";
85-
subject.label = "Test";
86-
await elementUpdated(subject);
78+
it("renders a zeta-icon when icon prop is set", async () => {
79+
subject.icon = "star";
80+
subject.label = "Test";
81+
await elementUpdated(subject);
8782

88-
const icon = subject.shadowRoot?.querySelector("zeta-icon");
89-
expect(icon).to.exist;
90-
expect(icon?.textContent).to.equal("star");
91-
});
83+
const icon = subject.shadowRoot?.querySelector("zeta-icon");
84+
expect(icon).to.exist;
85+
expect(icon?.textContent).to.equal("star");
86+
});
9287

93-
it("renders an indicator circle when icon is not set", async () => {
94-
subject.label = "Test";
95-
await elementUpdated(subject);
88+
it("renders an indicator circle when icon is not set", async () => {
89+
subject.label = "Test";
90+
await elementUpdated(subject);
9691

97-
const circle = subject.shadowRoot?.querySelector("svg circle");
98-
expect(circle).to.exist;
99-
});
92+
const circle = subject.shadowRoot?.querySelector("svg circle");
93+
expect(circle).to.exist;
94+
});
10095

101-
it("renders zeta-icon instead of indicator circle when icon is provided", async () => {
102-
subject.icon = "star";
103-
subject.label = "Test";
104-
await elementUpdated(subject);
96+
it("renders zeta-icon instead of indicator circle when icon is provided", async () => {
97+
subject.icon = "star";
98+
subject.label = "Test";
99+
await elementUpdated(subject);
105100

106-
const icon = subject.shadowRoot?.querySelector("zeta-icon");
107-
const circle = subject.shadowRoot?.querySelector("svg circle");
108-
expect(icon).to.exist;
109-
expect(circle).to.not.exist;
110-
});
101+
const icon = subject.shadowRoot?.querySelector("zeta-icon");
102+
const circle = subject.shadowRoot?.querySelector("svg circle");
103+
expect(icon).to.exist;
104+
expect(circle).to.not.exist;
111105
});
112106

113-
describe("showIcon prop", () => {
114-
it("defaults to true", () => {
115-
expect(subject.showIcon).to.be.true;
116-
});
107+
it("defaults to true", () => {
108+
expect(subject.showIcon).to.be.true;
109+
});
117110

118-
it("renders icon container when showIcon is true", async () => {
119-
subject.label = "Test";
120-
subject.showIcon = true;
121-
await elementUpdated(subject);
111+
it("renders icon container when showIcon is true", async () => {
112+
subject.label = "Test";
113+
subject.showIcon = true;
114+
await elementUpdated(subject);
122115

123-
const iconContainer = subject.shadowRoot?.querySelector("[part='icon-container']");
124-
expect(iconContainer).to.exist;
125-
});
116+
const iconContainer = subject.shadowRoot?.querySelector("[part='icon-container']");
117+
expect(iconContainer).to.exist;
118+
});
126119

127-
it("hides icon container when showIcon is false", async () => {
128-
subject.label = "Test";
129-
subject.showIcon = false;
130-
await elementUpdated(subject);
120+
it("hides icon container when showIcon is false", async () => {
121+
subject.label = "Test";
122+
subject.showIcon = false;
123+
await elementUpdated(subject);
131124

132-
const iconContainer = subject.shadowRoot?.querySelector("[part='icon-container']");
133-
expect(iconContainer).to.not.exist;
134-
});
125+
const iconContainer = subject.shadowRoot?.querySelector("[part='icon-container']");
126+
expect(iconContainer).to.not.exist;
127+
});
135128

136-
it("removes icon when showIcon is toggled from true to false", async () => {
137-
subject.label = "Test";
138-
subject.showIcon = true;
139-
await elementUpdated(subject);
140-
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.exist;
129+
it("removes icon when showIcon is toggled from true to false", async () => {
130+
subject.label = "Test";
131+
subject.showIcon = true;
132+
await elementUpdated(subject);
133+
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.exist;
141134

142-
subject.showIcon = false;
143-
await elementUpdated(subject);
144-
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.not.exist;
145-
});
135+
subject.showIcon = false;
136+
await elementUpdated(subject);
137+
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.not.exist;
146138
});
147139

148-
describe("slot", () => {
149-
it("renders slot content when no label prop is set", async () => {
150-
const componentWithSlot = await createComponent(`<zeta-status-label>Slotted Text Content</zeta-status-label>`);
140+
it("renders slot content when no label prop is set", async () => {
141+
const componentWithSlot = await createComponent(`<zeta-status-label>Slotted Text Content</zeta-status-label>`);
151142

152-
expect(componentWithSlot.textContent).to.include("Slotted Text Content");
153-
});
143+
expect(componentWithSlot.textContent).to.include("Slotted Text Content");
144+
});
154145

155-
it("does not render slot when label prop is set", async () => {
156-
const componentWithSlot = await createComponent(`<zeta-status-label label="Label Text">Slotted Text</zeta-status-label>`);
146+
it("does not render slot when label prop is set", async () => {
147+
const componentWithSlot = await createComponent(`<zeta-status-label label="Label Text">Slotted Text</zeta-status-label>`);
157148

158-
const textPart = componentWithSlot.shadowRoot?.querySelector("[part='text']");
159-
expect(textPart?.textContent).to.equal("Label Text");
160-
expect(textPart?.textContent).to.not.include("Slotted Text");
161-
});
149+
const textPart = componentWithSlot.shadowRoot?.querySelector("[part='text']");
150+
expect(textPart?.textContent).to.equal("Label Text");
151+
expect(textPart?.textContent).to.not.include("Slotted Text");
152+
});
162153

163-
it("supports multiple elements in slot", async () => {
164-
const componentWithSlot = await createComponent(`<zeta-status-label><span>Span Text</span> Extra Text</zeta-status-label>`);
154+
it("supports multiple elements in slot", async () => {
155+
const componentWithSlot = await createComponent(`<zeta-status-label><span>Span Text</span> Extra Text</zeta-status-label>`);
165156

166-
expect(componentWithSlot.textContent).to.include("Span Text");
167-
expect(componentWithSlot.textContent).to.include("Extra Text");
168-
});
157+
expect(componentWithSlot.textContent).to.include("Span Text");
158+
expect(componentWithSlot.textContent).to.include("Extra Text");
169159
});
170160

171-
describe("combination of props", () => {
172-
it("renders correctly with status, label, and icon", async () => {
173-
subject.status = "positive";
174-
subject.label = "Success";
175-
subject.icon = "star";
176-
await elementUpdated(subject);
161+
it("renders correctly with status, label, and icon", async () => {
162+
subject.status = "positive";
163+
subject.label = "Success";
164+
subject.icon = "star";
165+
await elementUpdated(subject);
177166

178-
expect(subject.status).to.equal("positive");
179-
expect(subject.shadowRoot?.querySelector("[part='text']")?.textContent).to.equal("Success");
180-
expect(subject.shadowRoot?.querySelector("zeta-icon")).to.exist;
181-
});
167+
expect(subject.status).to.equal("positive");
168+
expect(subject.shadowRoot?.querySelector("[part='text']")?.textContent).to.equal("Success");
169+
expect(subject.shadowRoot?.querySelector("zeta-icon")).to.exist;
170+
});
182171

183-
it("renders correctly with status and label without icon", async () => {
184-
subject.status = "warning";
185-
subject.label = "Warning";
186-
subject.showIcon = false;
187-
await elementUpdated(subject);
172+
it("renders correctly with status and label without icon", async () => {
173+
subject.status = "warning";
174+
subject.label = "Warning";
175+
subject.showIcon = false;
176+
await elementUpdated(subject);
188177

189-
expect(subject.status).to.equal("warning");
190-
expect(subject.shadowRoot?.querySelector("[part='text']")?.textContent).to.equal("Warning");
191-
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.not.exist;
192-
});
178+
expect(subject.status).to.equal("warning");
179+
expect(subject.shadowRoot?.querySelector("[part='text']")?.textContent).to.equal("Warning");
180+
expect(subject.shadowRoot?.querySelector("[part='icon-container']")).to.not.exist;
193181
});
194182
});
195-
196183
describe("Dimensions", () => {
197184
it("sets the default dimensions correctly", async () => {
198185
subject.setAttribute("label", `Label`);

0 commit comments

Comments
 (0)