fix closing search bar has not to trigger search (#2415)

This commit is contained in:
Eugenio Romano 2017-10-03 18:33:02 +01:00 committed by GitHub
parent be19fe93d0
commit ba908e5f0e
2 changed files with 24 additions and 2 deletions

View File

@ -1,13 +1,13 @@
<form #f="ngForm" (ngSubmit)="onSearch(f.value)" class="adf-search-form">
<div class="adf-search-container"
[@transitionMessages]="subscriptAnimationState">
<button md-button
<a md-button
*ngIf="expandable"
id="adf-search-button"
(click)="toggleSearchBar()"
class="adf-search-button">
<md-icon aria-label="search button">search</md-icon>
</button>
</a>
<div class="adf-search-field">
<md-input-container>
<input

View File

@ -340,6 +340,28 @@ describe('SearchControlComponent', () => {
}, 500);
});
it('click on the search button should not trigger the search when you click on it to close the search bar', (done) => {
spyOn(searchService, 'getQueryNodesPromise')
.and.returnValue(Promise.resolve(results));
component.liveSearchTerm = 'test';
fixture.detectChanges();
component.subscriptAnimationState = 'active';
let searchButton: any = element.querySelector('#adf-search-button');
searchButton.click();
setTimeout(() => {
fixture.detectChanges();
expect(component.liveSearchComponent.panelAnimationState).not.toBe('void');
let resultElement: Element = element.querySelector('#adf-search-results');
expect(resultElement).toBe(null);
done();
done();
}, 500);
});
it('click on the search button should open the input box when is close', (done) => {
fixture.detectChanges();
component.subscriptAnimationState = 'inactive';