Skip to content
Snippets Groups Projects
Commit cb22c094 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6129 refactor test for event emitter

parent d030b458
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ import { InstantSearchResult } from './instant-search.model';
[attr.aria-expanded]="results.length"
[control]="control"
aria-controls="results"
(clickInput)="showResults()"
(inputClicked)="showResults()"
#searchField
/>
<ods-aria-live-region [text]="ariaLiveText" />
......
import { EMPTY_STRING } from '@alfa-client/tech-shared';
import { getElementFromFixtureByType } from '@alfa-client/test-utils';
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';
......@@ -23,14 +24,14 @@ describe('SearchFieldComponent', () => {
expect(component).toBeTruthy();
});
describe('clickInput', () => {
describe('inputClicked', () => {
it('should emit event', () => {
component.inputClicked = <any>mock(EventEmitter);
const input = getElementFromFixtureByType(fixture, TextInputComponent);
const emitSpy = jest.spyOn(component.clickInput, 'emit');
input.clickEmitter.emit();
input.inputElement.nativeElement.click();
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(component.inputClicked.emit).toHaveBeenCalled();
});
});
......
......@@ -16,7 +16,7 @@ import { SearchIconComponent } from '../../icons/search-icon/search-icon.compone
[placeholder]="placeholder"
[withPrefix]="true"
[withSuffix]="true"
(clickEmitter)="clickInput.emit()"
(clickEmitter)="inputClicked.emit()"
role="combobox"
>
<ods-search-icon prefix aria-hidden="true" aria-label="Suchfeld" />
......@@ -30,7 +30,7 @@ export class SearchFieldComponent {
@Input() placeholder: string = EMPTY_STRING;
@Input() control = new FormControl(EMPTY_STRING);
@Output() clickInput: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
@Output() inputClicked: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
clearInput() {
this.control.setValue(EMPTY_STRING);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment