Skip to content

Commit d8f1178

Browse files
committed
Search service suggestion tests
1 parent d0ae23f commit d8f1178

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

src/app/shared/search/search.service.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,41 @@ describe('SearchService', () => {
146146
});
147147
});
148148

149+
describe('getSuggestionsFor', () => {
150+
let remoteDataMocks: Record<string, RemoteData<SearchObjects<any>>>;
151+
152+
beforeEach(() => {
153+
remoteDataMocks = {
154+
RequestPending: new RemoteData(undefined, msToLive, remoteDataTimestamp, RequestEntryState.RequestPending, undefined, undefined, undefined),
155+
ResponsePending: new RemoteData(undefined, msToLive, remoteDataTimestamp, RequestEntryState.ResponsePending, undefined, undefined, undefined),
156+
Success: new RemoteData(remoteDataTimestamp, msToLive, remoteDataTimestamp, RequestEntryState.Success, undefined, new SearchObjects(), 200),
157+
SuccessStale: new RemoteData(remoteDataTimestamp, msToLive, remoteDataTimestamp, RequestEntryState.SuccessStale, undefined, new SearchObjects(), 200),
158+
};
159+
});
160+
161+
it('should call getEndpoint on the halService', () => {
162+
spyOn(halService, 'getEndpoint').and.callThrough();
163+
164+
service.getSuggestionsFor('strawburster', 'geniuses').subscribe();
165+
166+
expect(halService.getEndpoint).toHaveBeenCalled();
167+
});
168+
169+
it('should send out the request on the request service', () => {
170+
service.getSuggestionsFor('strawburster', 'supermodels').subscribe();
171+
172+
expect(requestService.send).toHaveBeenCalled();
173+
});
174+
175+
it('should call buildFromUUID on the request service', () => {
176+
spyOn(remoteDataBuildService, 'buildFromRequestUUID').and.callThrough();
177+
178+
service.getSuggestionsFor('strawburster', 'astronauts').subscribe();
179+
180+
expect(remoteDataBuildService.buildFromRequestUUID).toHaveBeenCalled();
181+
});
182+
});
183+
149184
describe('search', () => {
150185
let remoteDataMocks: Record<string, RemoteData<SearchObjects<any>>>;
151186

0 commit comments

Comments
 (0)