Skip to content

Commit

Permalink
fix(data): DefaultDataService getAll httpOptions fix + test (#4134)
Browse files Browse the repository at this point in the history
Co-authored-by: thomas <t.welsch@wsa-electronic.de>
  • Loading branch information
Tom-Neo and thomas authored Nov 19, 2023
1 parent 9c8304a commit 213e4c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions modules/data/spec/dataservices/default-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ describe('DefaultDataService', () => {

req.error(errorEvent, { status: 404, statusText: 'Not Found' });
});

it('should pass httpOptions', (done) => {
const expectedParams = new HttpParams({ fromObject: { test: 123 } });
service
.getAll({ httpParams: { fromObject: { test: 123 } } })
.subscribe((heroes) => {
expect(heroes.length).toEqual(0);
done();
}, fail);

const req = httpTestingController.expectOne(heroesUrl + '?test=123');

expect(req.request.params).toEqual(expectedParams);

req.flush([]); // Respond with no heroes
});
});

describe('#getById', () => {
Expand Down
2 changes: 1 addition & 1 deletion modules/data/src/dataservices/default-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class DefaultDataService<T> implements EntityCollectionDataService<T> {
}

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

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

0 comments on commit 213e4c9

Please sign in to comment.