Skip to content

Commit ce0ae5a

Browse files
committed
chore(Checkbox): fix failing test
1 parent 18a3022 commit ce0ae5a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

test/checkbox.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ describe("<sgds-checkbox>", () => {
8282
expect(el.invalid).to.be.false;
8383
});
8484
it("id attribute should equal to label for attribute", async () => {
85-
const el = await fixture(html`<sgds-checkbox></sgds-checkbox>`);
85+
const el = await fixture(html`<sgds-checkbox>Label</sgds-checkbox>`);
8686
const input = el.shadowRoot?.querySelector("input");
8787
const label = el.shadowRoot?.querySelector("label");
88+
89+
expect(label).to.exist;
8890
expect(input?.getAttribute("id")).to.equal(label?.getAttribute("for"));
8991
});
9092

@@ -120,10 +122,14 @@ describe("<sgds-checkbox>", () => {
120122
});
121123

122124
it("should emit sgds-change event when label is clicked", async () => {
123-
const el = await fixture(html`<sgds-checkbox></sgds-checkbox>`);
125+
const el = await fixture(html`<sgds-checkbox>Label</sgds-checkbox>`);
124126
const toggleHandler = Sinon.spy();
125127
el.addEventListener("sgds-change", toggleHandler);
126-
el.shadowRoot?.querySelector("label")?.click();
128+
129+
const label = el.shadowRoot?.querySelector("label");
130+
expect(label).to.exist;
131+
label?.click();
132+
127133
expect(toggleHandler).to.have.been.calledOnce;
128134
});
129135

0 commit comments

Comments
 (0)