Skip to content

Commit 213e4c9

Browse files
Tom-Neothomas
andauthored
fix(data): DefaultDataService getAll httpOptions fix + test (#4134)
Co-authored-by: thomas <t.welsch@wsa-electronic.de>
1 parent 9c8304a commit 213e4c9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

modules/data/spec/dataservices/default-data.service.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ describe('DefaultDataService', () => {
216216

217217
req.error(errorEvent, { status: 404, statusText: 'Not Found' });
218218
});
219+
220+
it('should pass httpOptions', (done) => {
221+
const expectedParams = new HttpParams({ fromObject: { test: 123 } });
222+
service
223+
.getAll({ httpParams: { fromObject: { test: 123 } } })
224+
.subscribe((heroes) => {
225+
expect(heroes.length).toEqual(0);
226+
done();
227+
}, fail);
228+
229+
const req = httpTestingController.expectOne(heroesUrl + '?test=123');
230+
231+
expect(req.request.params).toEqual(expectedParams);
232+
233+
req.flush([]); // Respond with no heroes
234+
});
219235
});
220236

221237
describe('#getById', () => {

modules/data/src/dataservices/default-data.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class DefaultDataService<T> implements EntityCollectionDataService<T> {
9898
}
9999

100100
getAll(options?: HttpOptions): Observable<T[]> {
101-
return this.execute('GET', this.entitiesUrl, null, options);
101+
return this.execute('GET', this.entitiesUrl, null, null, options);
102102
}
103103

104104
getById(key: number | string, options?: HttpOptions): Observable<T> {

0 commit comments

Comments
 (0)