Skip to content

Commit e976a2a

Browse files
committed
test(form-check-input): indeterminate coverage
1 parent 38ecf8e commit e976a2a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

projects/coreui-angular/src/lib/form/form-check/form-check-input.directive.spec.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { FormCheckInputDirective } from './form-check-input.directive';
66
class MockElementRef extends ElementRef {}
77

88
@Component({
9-
template: '<input cFormCheckInput>',
9+
template: '<input cFormCheckInput [indeterminate]="indeterminate" [checked]="true">',
1010
imports: [FormCheckInputDirective]
1111
})
12-
class TestComponent {}
12+
class TestComponent {
13+
indeterminate = false;
14+
}
1315

1416
describe('FormCheckInputDirective', () => {
1517
let component: TestComponent;
@@ -21,11 +23,11 @@ describe('FormCheckInputDirective', () => {
2123
TestBed.configureTestingModule({
2224
imports: [FormCheckInputDirective, TestComponent],
2325
providers: [Renderer2, { provide: ElementRef, useClass: MockElementRef }]
24-
});
26+
}).compileComponents();
2527
fixture = TestBed.createComponent(TestComponent);
2628
component = fixture.componentInstance;
2729
inputEl = fixture.debugElement.query(By.directive(FormCheckInputDirective));
28-
// renderer = fixture.componentRef.injector.get(Renderer2 as Type<Renderer2>);
30+
fixture.detectChanges();
2931
});
3032

3133
it('should create an instance', () => {
@@ -38,4 +40,11 @@ describe('FormCheckInputDirective', () => {
3840
it('should have css classes', () => {
3941
expect(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
});

0 commit comments

Comments
 (0)