|
1 | 1 | import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; |
2 | | -import { ComponentFixture, TestBed, fakeAsync, tick, async } from "@angular/core/testing"; |
| 2 | +import { ComponentFixture, TestBed } from "@angular/core/testing"; |
3 | 3 | import { By } from "@angular/platform-browser"; |
4 | | -import { DebugElement } from "@angular/core"; |
5 | 4 | import { StaticIconModule } from "../icon/static-icon.module"; |
6 | 5 |
|
7 | | -import { Switch } from "./switch.component"; |
8 | | -import { Checkbox } from "../checkbox/checkbox.module"; |
| 6 | +import { Switch, SwitchChange } from "./switch.component"; |
9 | 7 |
|
10 | 8 | describe("Switch", () => { |
11 | 9 | let component: Switch; |
12 | 10 | let fixture: ComponentFixture<Switch>; |
13 | 11 | let labelElement: HTMLElement; |
14 | 12 | let buttonElement: HTMLElement; |
15 | | - let svgElement: HTMLElement; |
16 | 13 |
|
17 | 14 | beforeEach(() => { |
18 | 15 | TestBed.configureTestingModule({ |
@@ -64,4 +61,17 @@ describe("Switch", () => { |
64 | 61 | expect(labelElement.innerHTML).toContain("bx--toggle__check"); |
65 | 62 | }); |
66 | 63 |
|
| 64 | + it("should match the input checked value", () => { |
| 65 | + component.checked = true; |
| 66 | + fixture.detectChanges(); |
| 67 | + expect(buttonElement.attributes.getNamedItem("aria-checked").value).toEqual("true"); |
| 68 | + }); |
| 69 | + |
| 70 | + it("should emit SwitchChange event", (done: any) => { |
| 71 | + component.change.subscribe((data: any) => { |
| 72 | + expect(data instanceof SwitchChange).toEqual(true); |
| 73 | + done(); |
| 74 | + }); |
| 75 | + component.emitChangeEvent(); |
| 76 | + }); |
67 | 77 | }); |
0 commit comments