@@ -5,13 +5,14 @@ import { DebugElement } from "@angular/core";
55import { StaticIconModule } from "../icon/static-icon.module" ;
66
77import { SwitchComponent } from "./switch.component" ;
8+ import { CheckboxComponent } from "../checkbox/checkbox.module" ;
89
910describe ( "SwitchComponent" , ( ) => {
1011 let component : SwitchComponent ;
1112 let fixture : ComponentFixture < SwitchComponent > ;
12- let de : DebugElement ;
13- let el : HTMLElement ;
13+ let labelElement : HTMLElement ;
1414 let buttonElement : HTMLElement ;
15+ let svgElement : HTMLElement ;
1516
1617 beforeEach ( ( ) => {
1718 TestBed . configureTestingModule ( {
@@ -22,8 +23,8 @@ describe("SwitchComponent", () => {
2223
2324 fixture = TestBed . createComponent ( SwitchComponent ) ;
2425 component = fixture . componentInstance ;
25- de = fixture . debugElement . query ( By . css ( "label" ) ) ;
26- el = de . nativeElement ;
26+ fixture . detectChanges ( ) ;
27+ labelElement = fixture . debugElement . query ( By . css ( "label" ) ) . nativeElement ;
2728 buttonElement = fixture . debugElement . query ( By . css ( "input" ) ) . nativeElement ;
2829 } ) ;
2930
@@ -40,4 +41,21 @@ describe("SwitchComponent", () => {
4041 fixture . detectChanges ( ) ;
4142 expect ( component . checked ) . toBe ( false , "setting to off" ) ;
4243 } ) ;
44+
45+ it ( "should display small version of switch when size equals sm" , ( ) => {
46+ component . size = "sm" ;
47+ component . ngOnInit ( ) ;
48+ fixture . detectChanges ( ) ;
49+ expect ( buttonElement . className . includes ( "bx--toggle--small" ) ) . toEqual ( true ) ;
50+ } ) ;
51+
52+ it ( "should display SVG in small version of switch" , ( ) => {
53+ component . size = "sm" ;
54+ component . ngOnInit ( ) ;
55+ fixture . detectChanges ( ) ;
56+ labelElement = fixture . debugElement . query ( By . css ( "label" ) ) . nativeElement ;
57+ expect ( fixture . debugElement . query ( By . css ( "svg" ) ) . nativeElement ) . not . toBeNull ( ) ;
58+ expect ( labelElement . innerHTML ) . toContain ( "bx--toggle__check" ) ;
59+ } ) ;
60+
4361} ) ;
0 commit comments