Skip to content

Commit

Permalink
Merge pull request #92 from MaibornWolff/#88-fix-mw-switch
Browse files Browse the repository at this point in the history
#88: fix dynamic label in mw-switch; add tests
  • Loading branch information
Fuasmattn authored Mar 8, 2023
2 parents b9e090f + 3ff66e6 commit fe428c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 24 additions & 0 deletions mwui-stencil/src/components/mw-switch/mw-switch.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,28 @@ describe("GIVEN MwSwitch", () => {

expect(page.root.shadowRoot.querySelector(".label").innerHTML).toEqual(label);
});

it("SHOULD render off-text label WHEN value is false", async () => {
const offText = "off-text";
const onText = "on-text";
const page = await setup({
checked: false,
offText,
onText,
});

expect(page.root.shadowRoot.querySelector(".label").innerHTML).toEqual(offText);
});

it("SHOULD render on-text label WHEN value is true", async () => {
const offText = "off-text";
const onText = "on-text";
const page = await setup({
checked: true,
offText,
onText,
});

expect(page.root.shadowRoot.querySelector(".label").innerHTML).toEqual(onText);
});
});
1 change: 0 additions & 1 deletion mwui-stencil/src/components/mw-switch/mw-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class MwSwitch {

private toggleSwitch(event: Event & { path: unknown[] }): void {
(event.target as HTMLInputElement).blur();
(event.path[1] as HTMLInputElement).blur();
this.checked = this.checkbox.checked;
this.emitter.emit(event);
}
Expand Down

0 comments on commit fe428c6

Please sign in to comment.