import { EMPTY_STRING } from '@alfa-client/tech-shared'; import { getElementFromFixtureByType, mock } from '@alfa-client/test-utils'; import { EventEmitter } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl } from '@angular/forms'; import { TextInputComponent } from '../../form/text-input/text-input.component'; import { SearchFieldComponent } from './search-field.component'; describe('SearchFieldComponent', () => { let component: SearchFieldComponent; let fixture: ComponentFixture<SearchFieldComponent>; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [SearchFieldComponent], }).compileComponents(); fixture = TestBed.createComponent(SearchFieldComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); describe('inputClicked', () => { it('should emit event', () => { component.inputClicked = <any>mock(EventEmitter); const input = getElementFromFixtureByType(fixture, TextInputComponent); input.inputElement.nativeElement.click(); expect(component.inputClicked.emit).toHaveBeenCalled(); }); }); describe('clearValue', () => { it('should set empty value', () => { component.control = new FormControl('test'); component.clearInput(); expect(component.control.value).toBe(EMPTY_STRING); }); }); });