mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
56434: SearchResultsComponent and SearchConfigurationService test additions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<h2 *ngIf="!disableHeader">{{ getTitleKey() | translate }}</h2>
|
||||
<h2 *ngIf="!disableHeader" class="search-results-title">{{ getTitleKey() | translate }}</h2>
|
||||
<div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
||||
<ds-viewable-collection
|
||||
[config]="searchConfig.pagination"
|
||||
|
@@ -10,6 +10,7 @@ describe('SearchResultsComponent', () => {
|
||||
let comp: SearchResultsComponent;
|
||||
let fixture: ComponentFixture<SearchResultsComponent>;
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user