@@ -146,6 +146,45 @@ describe('SearchService', () => {
146146 } ) ;
147147 } ) ;
148148
149+ describe ( 'getSuggestionsFor' , ( ) => {
150+ let remoteDataMocks : Record < string , RemoteData < any > > ;
151+ let dictionary = 'supermodels' ;
152+ let query = 'strawburster' ;
153+
154+ beforeEach ( ( ) => {
155+ remoteDataMocks = {
156+ RequestPending : new RemoteData ( undefined , msToLive , remoteDataTimestamp , RequestEntryState . RequestPending , undefined , undefined , undefined ) ,
157+ ResponsePending : new RemoteData ( undefined , msToLive , remoteDataTimestamp , RequestEntryState . ResponsePending , undefined , undefined , undefined ) ,
158+ Success : new RemoteData ( remoteDataTimestamp , msToLive , remoteDataTimestamp , RequestEntryState . Success , undefined ,
159+ { suggest : { [ dictionary ] : { [ query ] : [ 'strawburster' , 'lesser' , 'known' , 'people' ] } } } ,
160+ 200 ) ,
161+ SuccessStale : new RemoteData ( remoteDataTimestamp , msToLive , remoteDataTimestamp , RequestEntryState . SuccessStale , undefined , new SearchObjects ( ) , 200 ) ,
162+ } ;
163+ } ) ;
164+
165+ it ( 'should call getEndpoint on the halService with the suggest endpoint' , ( ) => {
166+ spyOn ( halService , 'getEndpoint' ) . and . callThrough ( ) ;
167+
168+ service . getSuggestionsFor ( dictionary , query ) . subscribe ( ) ;
169+
170+ expect ( halService . getEndpoint ) . toHaveBeenCalledWith ( 'discover' ) ;
171+ } ) ;
172+
173+ it ( 'should send out the request on the request service' , ( ) => {
174+ service . getSuggestionsFor ( dictionary , query ) . subscribe ( ) ;
175+
176+ expect ( requestService . send ) . toHaveBeenCalled ( ) ;
177+ } ) ;
178+
179+ it ( 'should call buildFromUUID on the request service' , ( ) => {
180+ spyOn ( remoteDataBuildService , 'buildFromRequestUUID' ) . and . callThrough ( ) ;
181+
182+ service . getSuggestionsFor ( dictionary , query ) . subscribe ( ) ;
183+
184+ expect ( remoteDataBuildService . buildFromRequestUUID ) . toHaveBeenCalled ( ) ;
185+ } ) ;
186+ } ) ;
187+
149188 describe ( 'search' , ( ) => {
150189 let remoteDataMocks : Record < string , RemoteData < SearchObjects < any > > > ;
151190
0 commit comments