@@ -5,7 +5,7 @@ import { RouterTestingModule } from '@angular/router/testing';
55import { Store } from '@ngrx/store' ;
66import { TranslateModule } from '@ngx-translate/core' ;
77import { cold } from 'jasmine-marbles' ;
8- import { Observable , BehaviorSubject , of as observableOf } from 'rxjs' ;
8+ import { BehaviorSubject , Observable , of as observableOf } from 'rxjs' ;
99import { SortDirection , SortOptions } from '../../core/cache/models/sort-options.model' ;
1010import { CommunityDataService } from '../../core/data/community-data.service' ;
1111import { HostWindowService } from '../host-window.service' ;
@@ -30,6 +30,8 @@ import { RemoteData } from '../../core/data/remote-data';
3030import { SearchObjects } from './models/search-objects.model' ;
3131import { DSpaceObject } from '../../core/shared/dspace-object.model' ;
3232import { SearchManager } from '../../core/browse/search-manager' ;
33+ import { SearchFilterConfig } from './models/search-filter-config.model' ;
34+ import { FilterType } from './models/filter-type.model' ;
3335
3436let comp : SearchComponent ;
3537let fixture : ComponentFixture < SearchComponent > ;
@@ -96,10 +98,38 @@ const mockSearchResults: SearchObjects<DSpaceObject> = Object.assign(new SearchO
9698} ) ;
9799const mockResultsRD : RemoteData < SearchObjects < DSpaceObject > > = createSuccessfulRemoteDataObject ( mockSearchResults ) ;
98100const mockResultsRD$ : Observable < RemoteData < SearchObjects < DSpaceObject > > > = observableOf ( mockResultsRD ) ;
101+
102+ const mockFilterConfig : SearchFilterConfig = Object . assign ( new SearchFilterConfig ( ) , {
103+ name : 'test1' ,
104+ filterType : FilterType . text ,
105+ hasFacets : false ,
106+ isOpenByDefault : false ,
107+ pageSize : 2
108+ } ) ;
109+ const mockFilterConfig2 : SearchFilterConfig = Object . assign ( new SearchFilterConfig ( ) , {
110+ name : 'test2' ,
111+ filterType : FilterType . text ,
112+ hasFacets : false ,
113+ isOpenByDefault : false ,
114+ pageSize : 1
115+ } ) ;
116+ const mockChartFilterConfig : SearchFilterConfig = Object . assign ( new SearchFilterConfig ( ) , {
117+ name : 'line' ,
118+ filterType : FilterType [ 'chart.line' ] ,
119+ hasFacets : false ,
120+ isOpenByDefault : false ,
121+ pageSize : 1
122+ } ) ;
123+
124+ const filtersConfigRD = createSuccessfulRemoteDataObject ( [ mockFilterConfig , mockFilterConfig2 , mockChartFilterConfig ] ) ;
125+ const resultFiltersConfigRD = createSuccessfulRemoteDataObject ( [ mockFilterConfig , mockFilterConfig2 ] ) ;
126+ const filtersConfigRD$ = observableOf ( filtersConfigRD ) ;
127+
99128const searchServiceStub = jasmine . createSpyObj ( 'SearchService' , {
100129 getSearchLink : '/search' ,
101130 getScopes : observableOf ( [ 'test-scope' ] ) ,
102- getSearchConfigurationFor : createSuccessfulRemoteDataObject$ ( searchConfig )
131+ getSearchConfigurationFor : createSuccessfulRemoteDataObject$ ( searchConfig ) ,
132+ getConfig : filtersConfigRD$ ,
103133} ) ;
104134const searchManagerStub = jasmine . createSpyObj ( 'SearchManager' , {
105135 search : mockResultsRD$ ,
@@ -152,6 +182,7 @@ const routeServiceStub = {
152182
153183const searchConfigurationServiceStub = jasmine . createSpyObj ( 'SearchConfigurationService' , {
154184 getConfigurationSortOptions : jasmine . createSpy ( 'getConfigurationSortOptions' ) ,
185+ getConfig : filtersConfigRD$ ,
155186 getConfigurationSearchConfig : jasmine . createSpy ( 'getConfigurationSearchConfig' ) ,
156187 getCurrentConfiguration : jasmine . createSpy ( 'getCurrentConfiguration' ) ,
157188 getCurrentScope : jasmine . createSpy ( 'getCurrentScope' ) ,
@@ -273,6 +304,15 @@ describe('SearchComponent', () => {
273304 } ) ) ;
274305 } ) ) ;
275306
307+ it ( 'should retrieve Search Filters' , fakeAsync ( ( ) => {
308+ fixture . detectChanges ( ) ;
309+ tick ( 100 ) ;
310+ const expectedResults = resultFiltersConfigRD ;
311+ expect ( comp . filtersRD$ ) . toBeObservable ( cold ( 'b' , {
312+ b : expectedResults
313+ } ) ) ;
314+ } ) ) ;
315+
276316 it ( 'should emit resultFound event' , fakeAsync ( ( ) => {
277317 spyOn ( comp . resultFound , 'emit' ) ;
278318 const expectedResults = mockSearchResults ;
0 commit comments