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

Merge remote-tracking branch 'origin/OZG-6129-zufi-searchbar' into OZG-6129-zufi-searchbar

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