Skip to content

Commit

Permalink
[ADF-5176] - added test for the clear check
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoAlbano committed Jul 7, 2020
1 parent 172aa67 commit 5e4ef51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -188,4 +188,25 @@ describe('SearchHeaderComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
});

it('should emit the clear event when no filter has valued applied', async (done) => {
spyOn(queryBuilder, 'isNoFilterActive').and.returnValue(true);
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
spyOn(queryBuilder, 'buildQuery').and.returnValue({});
spyOn(component.widgetContainer, 'resetInnerWidget').and.stub();
component.widgetContainer.componentRef.instance.value = '';
const fakeEvent = jasmine.createSpyObj('event', ['stopPropagation']);
component.clear.subscribe(() => {
done();
});

const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button');
menuButton.click();
fixture.detectChanges();
await fixture.whenStable();
const applyButton = fixture.debugElement.query(By.css('#apply-filter-button'));
applyButton.triggerEventHandler('click', fakeEvent);
fixture.detectChanges();
await fixture.whenStable();
});
});
Expand Up @@ -31,7 +31,7 @@ import {
import { DataColumn, TranslationService } from '@alfresco/adf-core';
import { SearchWidgetContainerComponent } from '../search-widget-container/search-widget-container.component';
import { SearchHeaderQueryBuilderService } from '../../search-header-query-builder.service';
import { NodePaging, QueryBody } from '@alfresco/js-api';
import { NodePaging } from '@alfresco/js-api';
import { SearchCategory } from '../../search-category.interface';
import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token';
import { Subject } from 'rxjs';
Expand Down

0 comments on commit 5e4ef51

Please sign in to comment.