import { ComponentFixture, TestBed } from '@angular/core/testing' import { CheckComponent } from './check.component' import { FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule, } from '@angular/forms' describe('CheckComponent', () => { let component: CheckComponent let fixture: ComponentFixture let input: HTMLInputElement beforeEach(async () => { TestBed.configureTestingModule({ declarations: [CheckComponent], providers: [], imports: [FormsModule, ReactiveFormsModule], }).compileComponents() fixture = TestBed.createComponent(CheckComponent) fixture.debugElement.injector.get(NG_VALUE_ACCESSOR) component = fixture.componentInstance fixture.detectChanges() input = component.inputField.nativeElement }) it('should support use of checkbox', () => { input.checked = true input.dispatchEvent(new Event('change')) fixture.detectChanges() expect(component.value).toBeTruthy() input.checked = false input.dispatchEvent(new Event('change')) fixture.detectChanges() expect(component.value).toBeFalsy() }) })