fixed test and search facet issue for mydspace

This commit is contained in:
lotte
2019-05-16 17:11:13 +02:00
parent cbde7fc679
commit 0bdb0ba2b7
4 changed files with 15 additions and 7 deletions

View File

@@ -6,7 +6,8 @@
id="search-sidebar" id="search-sidebar"
[configurationList]="(configurationList$ | async)" [configurationList]="(configurationList$ | async)"
[resultCount]="(resultsRD$ | async)?.payload.totalElements" [resultCount]="(resultsRD$ | async)?.payload.totalElements"
[viewModeList]="viewModeList"></ds-search-sidebar> [viewModeList]="viewModeList"
[inPlaceSearch]="inPlaceSearch"></ds-search-sidebar>
<div class="col-12 col-md-9"> <div class="col-12 col-md-9">
<ds-search-form id="search-form" <ds-search-form id="search-form"
[query]="(searchOptions$ | async)?.query" [query]="(searchOptions$ | async)?.query"

View File

@@ -62,7 +62,6 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
ngOnInit(): void { ngOnInit(): void {
this.sub = observableCombineLatest(this.selectedValues$, this.searchConfigService.searchOptions) this.sub = observableCombineLatest(this.selectedValues$, this.searchConfigService.searchOptions)
.subscribe(([selectedValues, searchOptions]) => { .subscribe(([selectedValues, searchOptions]) => {
console.log(selectedValues);
this.updateRemoveParams(selectedValues) this.updateRemoveParams(selectedValues)
}); });
} }

View File

@@ -19,6 +19,7 @@ import { SearchFacetFilterComponent } from './search-facet-filter.component';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service-stub'; import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service-stub';
import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component'; import { SEARCH_CONFIG_SERVICE } from '../../../../+my-dspace-page/my-dspace-page.component';
import { tap } from 'rxjs/operators';
describe('SearchFacetFilterComponent', () => { describe('SearchFacetFilterComponent', () => {
let comp: SearchFacetFilterComponent; let comp: SearchFacetFilterComponent;
@@ -69,7 +70,7 @@ describe('SearchFacetFilterComponent', () => {
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) }, { provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: Router, useValue: new RouterStub() }, { provide: Router, useValue: new RouterStub() },
{ provide: FILTER_CONFIG, useValue: new SearchFilterConfig() }, { provide: FILTER_CONFIG, useValue: new SearchFilterConfig() },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} }, { provide: RemoteDataBuildService, useValue: { aggregate: () => observableOf({}) } },
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() }, { provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
{ provide: IN_PLACE_SEARCH, useValue: false }, { provide: IN_PLACE_SEARCH, useValue: false },
{ {
@@ -173,7 +174,14 @@ describe('SearchFacetFilterComponent', () => {
const searchUrl = '/search/path'; const searchUrl = '/search/path';
const testValue = 'test'; const testValue = 'test';
const data = testValue; const data = testValue;
beforeEach(() => { beforeEach(() => {
comp.selectedValues$ = observableOf(selectedValues.map((value) =>
Object.assign(new FacetValue(), {
label: value,
value: value
})));
fixture.detectChanges();
spyOn(comp, 'getSearchLink').and.returnValue(searchUrl); spyOn(comp, 'getSearchLink').and.returnValue(searchUrl);
comp.onSubmit(data); comp.onSubmit(data);
}); });
@@ -193,9 +201,9 @@ describe('SearchFacetFilterComponent', () => {
}); });
it('should call showFirstPageOnly and empty the filter', () => { it('should call showFirstPageOnly and empty the filter', () => {
expect(comp.animationState).toEqual('loading'); expect(comp.animationState).toEqual('loading');
expect((comp as any).collapseNextUpdate).toBeTruthy(); expect((comp as any).collapseNextUpdate).toBeTruthy();
expect(comp.filter).toEqual(''); expect(comp.filter).toEqual('');
}); });
}); });

View File

@@ -137,7 +137,7 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
this.selectedValues$ = this.filterService.getSelectedValuesForFilter(this.filterConfig).pipe( this.selectedValues$ = this.filterService.getSelectedValuesForFilter(this.filterConfig).pipe(
map((selectedValues) => { map((selectedValues) => {
return selectedValues.map((value: string) => { return selectedValues.map((value: string) => {
const fValue = [].concat(...rd.payload.map((page) => page.page)).find((facetValue: FacetValue) => facetValue.value === value) const fValue = [].concat(...rd.payload.map((page) => page.page)).find((facetValue: FacetValue) => facetValue.value === value);
if (hasValue(fValue)) { if (hasValue(fValue)) {
return fValue; return fValue;
} }