diff --git a/src/app/+search-page/search-results/search-results.component.html b/src/app/+search-page/search-results/search-results.component.html
index b685d0b28d..126efecbf9 100644
--- a/src/app/+search-page/search-results/search-results.component.html
+++ b/src/app/+search-page/search-results/search-results.component.html
@@ -1,4 +1,4 @@
-
{{ getTitleKey() | translate }}
+{{ getTitleKey() | translate }}
0" @fadeIn>
{
let comp: SearchResultsComponent;
let fixture: ComponentFixture;
let heading: DebugElement;
+ let title: DebugElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -23,18 +24,42 @@ describe('SearchResultsComponent', () => {
fixture = TestBed.createComponent(SearchResultsComponent);
comp = fixture.componentInstance; // SearchFormComponent test instance
heading = fixture.debugElement.query(By.css('heading'));
+ title = fixture.debugElement.query(By.css('.search-results-title'));
});
- it('should display heading when results are not empty', fakeAsync(() => {
- (comp as any).searchResults = 'test';
- (comp as any).searchConfig = {pagination: ''};
- fixture.detectChanges();
- tick();
- expect(heading).toBeDefined();
- }));
+ describe('when results are not empty', () => {
+ beforeEach(() => {
+ (comp as any).searchResults = 'test';
+ (comp as any).searchConfig = {pagination: ''};
+ fixture.detectChanges();
+ });
- it('should not display heading when results is empty', () => {
- expect(heading).toBeNull();
+ it('should display heading',() => {
+ expect(heading).toBeDefined();
+ });
+
+ describe('when disableHeader is not set', () => {
+ it('should not display a title',() => {
+ expect(title).toBeNull();
+ });
+ });
+
+ describe('when disableHeader is set', () => {
+ beforeEach(() => {
+ comp.disableHeader = true;
+ fixture.detectChanges();
+ });
+
+ it('should display a title',() => {
+ expect(title).toBeDefined();
+ });
+ });
+ });
+
+ describe('when results are empty', () => {
+ it('should not display heading', () => {
+ expect(heading).toBeNull();
+ });
});
});
diff --git a/src/app/+search-page/search-service/search-configuration.service.spec.ts b/src/app/+search-page/search-service/search-configuration.service.spec.ts
index 6588da858f..9557fa9c1e 100644
--- a/src/app/+search-page/search-service/search-configuration.service.spec.ts
+++ b/src/app/+search-page/search-service/search-configuration.service.spec.ts
@@ -147,4 +147,29 @@ describe('SearchConfigurationService', () => {
});
});
});
+
+ describe('when getCurrentFixedFilter is called', () => {
+ beforeEach(() => {
+ service.getCurrentFixedFilter();
+ });
+ it('should call getRouteParameterValue on the routeService with parameter name \'filter\'', () => {
+ expect((service as any).routeService.getRouteParameterValue).toHaveBeenCalledWith('filter');
+ });
+ });
+
+ describe('when updateFixedFilter is called', () => {
+ const filter = 'filter';
+
+ beforeEach(() => {
+ service.updateFixedFilter(filter);
+ });
+
+ it('should update the paginated search options with the correct fixed filter', () => {
+ expect(service.paginatedSearchOptions.getValue().fixedFilter).toEqual(filter);
+ });
+
+ it('should update the search options with the correct fixed filter', () => {
+ expect(service.searchOptions.getValue().fixedFilter).toEqual(filter);
+ });
+ });
});