@@ -6,10 +6,12 @@ import { FormCheckInputDirective } from './form-check-input.directive';
6
6
class MockElementRef extends ElementRef { }
7
7
8
8
@Component ( {
9
- template : '<input cFormCheckInput>' ,
9
+ template : '<input cFormCheckInput [indeterminate]="indeterminate" [checked]="true" >' ,
10
10
imports : [ FormCheckInputDirective ]
11
11
} )
12
- class TestComponent { }
12
+ class TestComponent {
13
+ indeterminate = false ;
14
+ }
13
15
14
16
describe ( 'FormCheckInputDirective' , ( ) => {
15
17
let component : TestComponent ;
@@ -21,11 +23,11 @@ describe('FormCheckInputDirective', () => {
21
23
TestBed . configureTestingModule ( {
22
24
imports : [ FormCheckInputDirective , TestComponent ] ,
23
25
providers : [ Renderer2 , { provide : ElementRef , useClass : MockElementRef } ]
24
- } ) ;
26
+ } ) . compileComponents ( ) ;
25
27
fixture = TestBed . createComponent ( TestComponent ) ;
26
28
component = fixture . componentInstance ;
27
29
inputEl = fixture . debugElement . query ( By . directive ( FormCheckInputDirective ) ) ;
28
- // renderer = fixture.componentRef.injector.get(Renderer2 as Type<Renderer2> );
30
+ fixture . detectChanges ( ) ;
29
31
} ) ;
30
32
31
33
it ( 'should create an instance' , ( ) => {
@@ -38,4 +40,11 @@ describe('FormCheckInputDirective', () => {
38
40
it ( 'should have css classes' , ( ) => {
39
41
expect ( inputEl . nativeElement ) . toHaveClass ( 'form-check-input' ) ;
40
42
} ) ;
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
+ } ) ;
41
50
} ) ;
0 commit comments