mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +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>
|
<div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="searchConfig.pagination"
|
[config]="searchConfig.pagination"
|
||||||
|
@@ -10,6 +10,7 @@ describe('SearchResultsComponent', () => {
|
|||||||
let comp: SearchResultsComponent;
|
let comp: SearchResultsComponent;
|
||||||
let fixture: ComponentFixture<SearchResultsComponent>;
|
let fixture: ComponentFixture<SearchResultsComponent>;
|
||||||
let heading: DebugElement;
|
let heading: DebugElement;
|
||||||
|
let title: DebugElement;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -23,20 +24,44 @@ describe('SearchResultsComponent', () => {
|
|||||||
fixture = TestBed.createComponent(SearchResultsComponent);
|
fixture = TestBed.createComponent(SearchResultsComponent);
|
||||||
comp = fixture.componentInstance; // SearchFormComponent test instance
|
comp = fixture.componentInstance; // SearchFormComponent test instance
|
||||||
heading = fixture.debugElement.query(By.css('heading'));
|
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(() => {
|
describe('when results are not empty', () => {
|
||||||
|
beforeEach(() => {
|
||||||
(comp as any).searchResults = 'test';
|
(comp as any).searchResults = 'test';
|
||||||
(comp as any).searchConfig = {pagination: ''};
|
(comp as any).searchConfig = {pagination: ''};
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
tick();
|
});
|
||||||
expect(heading).toBeDefined();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should not display heading when results is empty', () => {
|
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();
|
expect(heading).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
export const objects = [
|
export const objects = [
|
||||||
Object.assign(new Community(), {
|
Object.assign(new Community(), {
|
||||||
|
@@ -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