@@ -6,10 +6,12 @@ import { FormCheckInputDirective } from './form-check-input.directive';
66class MockElementRef extends ElementRef { }
77
88@Component ( {
9- template :'<input cFormCheckInput>' ,
9+ template :'<input cFormCheckInput [indeterminate]="indeterminate" [checked]="true" >' ,
1010imports :[ FormCheckInputDirective ]
1111} )
12- class TestComponent { }
12+ class TestComponent {
13+ indeterminate = false ;
14+ }
1315
1416describe ( 'FormCheckInputDirective' , ( ) => {
1517let component :TestComponent ;
@@ -21,11 +23,11 @@ describe('FormCheckInputDirective', () => {
2123TestBed . configureTestingModule ( {
2224imports :[ FormCheckInputDirective , TestComponent ] ,
2325providers :[ Renderer2 , { provide :ElementRef , useClass :MockElementRef } ]
24- } ) ;
26+ } ) . compileComponents ( ) ;
2527fixture = TestBed . createComponent ( TestComponent ) ;
2628component = fixture . componentInstance ;
2729inputEl = fixture . debugElement . query ( By . directive ( FormCheckInputDirective ) ) ;
28- // renderer = fixture.componentRef.injector.get(Renderer2 as Type<Renderer2> );
30+ fixture . detectChanges ( ) ;
2931} ) ;
3032
3133it ( 'should create an instance' , ( ) => {
@@ -38,4 +40,11 @@ describe('FormCheckInputDirective', () => {
3840it ( 'should have css classes' , ( ) => {
3941expect ( inputEl . nativeElement ) . toHaveClass ( 'form-check-input' ) ;
4042} ) ;
43+
44+ it ( 'should have indeterminate state' , ( ) => {
45+ component . indeterminate = true ;
46+ fixture . detectChanges ( ) ;
47+ expect ( inputEl . nativeElement . checked ) . toBeFalse ( ) ;
48+ expect ( inputEl . nativeElement . indeterminate ) . toBeTrue ( ) ;
49+ } ) ;
4150} ) ;