Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#88: fix dynamic label in mw-switch; add tests #92

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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