@@ -26,6 +26,8 @@ import { SearchConfigurationService } from './search-configuration.service';
2626import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub' ;
2727import { RequestEntry } from '../../data/request-entry.model' ;
2828import { Angulartics2 } from 'angulartics2' ;
29+ import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model' ;
30+ import anything = jasmine . anything ;
2931
3032@Component ( { template : '' } )
3133class DummyComponent {
@@ -36,7 +38,7 @@ describe('SearchService', () => {
3638 let searchService : SearchService ;
3739 const router = new RouterStub ( ) ;
3840 const route = new ActivatedRouteStub ( ) ;
39- const searchConfigService = { paginationID : 'page-id' } ;
41+ const searchConfigService = { paginationID : 'page-id' } ;
4042 beforeEach ( ( ) => {
4143 TestBed . configureTestingModule ( {
4244 imports : [
@@ -103,7 +105,8 @@ describe('SearchService', () => {
103105 } ;
104106
105107 const paginationService = new PaginationServiceStub ( ) ;
106- const searchConfigService = { paginationID : 'page-id' } ;
108+ const searchConfigService = { paginationID : 'page-id' } ;
109+ const requestService = getMockRequestService ( ) ;
107110
108111 beforeEach ( ( ) => {
109112 TestBed . configureTestingModule ( {
@@ -119,7 +122,7 @@ describe('SearchService', () => {
119122 providers : [
120123 { provide : Router , useValue : router } ,
121124 { provide : RouteService , useValue : routeServiceStub } ,
122- { provide : RequestService , useValue : getMockRequestService ( ) } ,
125+ { provide : RequestService , useValue : requestService } ,
123126 { provide : RemoteDataBuildService , useValue : remoteDataBuildService } ,
124127 { provide : HALEndpointService , useValue : halService } ,
125128 { provide : CommunityDataService , useValue : { } } ,
@@ -138,13 +141,13 @@ describe('SearchService', () => {
138141
139142 it ( 'should call the navigate method on the Router with view mode list parameter as a parameter when setViewMode is called' , ( ) => {
140143 searchService . setViewMode ( ViewMode . ListElement ) ;
141- expect ( paginationService . updateRouteWithUrl ) . toHaveBeenCalledWith ( 'page-id' , [ '/search' ] , { page : 1 } , { view : ViewMode . ListElement }
144+ expect ( paginationService . updateRouteWithUrl ) . toHaveBeenCalledWith ( 'page-id' , [ '/search' ] , { page : 1 } , { view : ViewMode . ListElement }
142145 ) ;
143146 } ) ;
144147
145148 it ( 'should call the navigate method on the Router with view mode grid parameter as a parameter when setViewMode is called' , ( ) => {
146149 searchService . setViewMode ( ViewMode . GridElement ) ;
147- expect ( paginationService . updateRouteWithUrl ) . toHaveBeenCalledWith ( 'page-id' , [ '/search' ] , { page : 1 } , { view : ViewMode . GridElement }
150+ expect ( paginationService . updateRouteWithUrl ) . toHaveBeenCalledWith ( 'page-id' , [ '/search' ] , { page : 1 } , { view : ViewMode . GridElement }
148151 ) ;
149152 } ) ;
150153
@@ -191,5 +194,23 @@ describe('SearchService', () => {
191194 expect ( ( searchService as any ) . rdb . buildFromHref ) . toHaveBeenCalledWith ( endPoint ) ;
192195 } ) ;
193196 } ) ;
197+
198+ describe ( 'when getFacetValuesFor is called with a filterQuery' , ( ) => {
199+ it ( 'should add the encoded filterQuery to the args list' , ( ) => {
200+ jasmine . getEnv ( ) . allowRespy ( true ) ;
201+ const spyRequest = spyOn ( ( searchService as any ) , 'request' ) . and . stub ( ) ;
202+ spyOn ( requestService , 'send' ) . and . returnValue ( true ) ;
203+ const searchFilterConfig = new SearchFilterConfig ( ) ;
204+ searchFilterConfig . _links = {
205+ self : {
206+ href : 'https://demo.dspace.org/' ,
207+ } ,
208+ } ;
209+
210+ searchService . getFacetValuesFor ( searchFilterConfig , 1 , undefined , 'filter&Query' ) ;
211+
212+ expect ( spyRequest ) . toHaveBeenCalledWith ( anything ( ) , 'https://demo.dspace.org?page=0&size=5&prefix=filter%26Query' ) ;
213+ } ) ;
214+ } ) ;
194215 } ) ;
195216} ) ;
0 commit comments