Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: simulated HTTP errors now delayed as expected (#182)
Browse files Browse the repository at this point in the history
closes #180

also fixes type error (#180)
  • Loading branch information
wardbell authored Mar 9, 2018
1 parent f673b1c commit 25c6a21
Show file tree
Hide file tree
Showing 17 changed files with 8,153 additions and 21 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ because this is a development tool, not a production product.
We do try to tell you about such changes in this `CHANGELOG.md`
and we fix bugs as fast as we can.

<a id="0.5.2"></a>
<a id="0.5.4"></a>
## 0.5.4 (2018-03-09)

Simulated HTTP error responses were not delaying the prescribed time when using RxJS `delay()`
because it was short-circuited by the ErrorResponse.
New `delayResponse` function does it right.
Should not break you unless you incorrectly expected no delay for errors.

Also, this library no longer calls RxJS `delay()` which may make testing with it easier
(Angular TestBed does not handle RxJS `delay()` well because that operator uses `interval()`).

Also fixes type error (issue #180).

<a id="0.5.3"></a>
## 0.5.3 (2018-01-06)
Can make use of `HttpParams` which yields a `request.urlWithParams`.
Added supporting `HeroService.searchHeroes(term: string)` and test.
Expand Down
4 changes: 2 additions & 2 deletions backend.service.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend.service.js.map

Large diffs are not rendered by default.

38 changes: 32 additions & 6 deletions bundles/in-memory-web-api.umd.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions delay-response.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Observable } from 'rxjs/Observable';
/** adds specified delay (in ms) to both next and error channels of the response observable */
export declare function delayResponse<T>(response$: Observable<T>, delayMs: number): Observable<T>;
27 changes: 27 additions & 0 deletions delay-response.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions delay-response.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions delay-response.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"__symbolic":"module","version":3,"metadata":{"delayResponse":{"__symbolic":"function","parameters":["response$","delayMs"],"value":{"__symbolic":"error","message":"Function call not supported","line":5,"character":27}}}},{"__symbolic":"module","version":1,"metadata":{"delayResponse":{"__symbolic":"function","parameters":["response$","delayMs"],"value":{"__symbolic":"error","message":"Function call not supported","line":5,"character":27}}}}]
4 changes: 2 additions & 2 deletions http-client-backend.service.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpBackend, HttpHeaders, HttpRequest, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
import { HttpBackend, HttpEvent, HttpHeaders, HttpRequest, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { InMemoryBackendConfigArgs, InMemoryDbService, ResponseOptions } from './interfaces';
import { BackendService } from './backend.service';
Expand Down Expand Up @@ -32,7 +32,7 @@ import { BackendService } from './backend.service';
export declare class HttpClientBackendService extends BackendService implements HttpBackend {
private xhrFactory;
constructor(inMemDbService: InMemoryDbService, config: InMemoryBackendConfigArgs, xhrFactory: XhrFactory);
handle(req: HttpRequest<any>): Observable<HttpResponse<any>>;
handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
protected getJsonBody(req: HttpRequest<any>): any;
protected getRequestMethod(req: HttpRequest<any>): string;
protected createHeaders(headers: {
Expand Down
2 changes: 1 addition & 1 deletion http-client-backend.service.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25c6a21

Please sign in to comment.