Skip to content

Commit

Permalink
UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingle Jia committed Jul 25, 2020
1 parent 3b8ac66 commit 2bb8c7f
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/toggle/toggle.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe("Toggle", () => {
expect(component instanceof Toggle).toBe(true);
});

it("should have input with class 'bx--toggle'", () => {
expect(buttonElement.className.includes("bx--toggle")).toEqual(true);
it("should have input with class 'bx--toggle-input'", () => {
expect(buttonElement.className.includes("bx--toggle-input")).toEqual(true);
component.size = "sm";
fixture.detectChanges();
expect(buttonElement.className.includes("bx--toggle")).toEqual(true);
expect(buttonElement.className.includes("bx--toggle-input")).toEqual(true);
});

it("should change state", () => {
Expand All @@ -46,18 +46,10 @@ describe("Toggle", () => {
});

it("should display small version of toggle when size equals sm", () => {
expect(buttonElement.className.includes("bx--toggle--small")).toEqual(false);
expect(buttonElement.className.includes("bx--toggle-input--small")).toEqual(false);
component.size = "sm";
fixture.detectChanges();
expect(buttonElement.className.includes("bx--toggle--small")).toEqual(true);
});

it("should display SVG in small version of toggle", () => {
component.size = "sm";
fixture.detectChanges();
labelElement = fixture.debugElement.query(By.css("label")).nativeElement;
expect(fixture.debugElement.query(By.css("svg")).nativeElement).not.toBeNull();
expect(labelElement.innerHTML).toContain("bx--toggle__check");
expect(buttonElement.className.includes("bx--toggle-input--small")).toEqual(true);
});

it("should match the input checked value", () => {
Expand Down

0 comments on commit 2bb8c7f

Please sign in to comment.