From ec198b0dc6c503cad4c18fdb1480ad2d8adab305 Mon Sep 17 00:00:00 2001 From: Phong Huynh Date: Fri, 27 May 2016 13:10:53 -0400 Subject: [PATCH] docs(MockConnection) add mockError usage example (#8888) --- modules/@angular/http/testing/mock_backend.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/@angular/http/testing/mock_backend.ts b/modules/@angular/http/testing/mock_backend.ts index 191d37bc2c..7f6f575ef2 100644 --- a/modules/@angular/http/testing/mock_backend.ts +++ b/modules/@angular/http/testing/mock_backend.ts @@ -81,6 +81,16 @@ export class MockConnection implements Connection { * Emits the provided error object as an error to the {@link Response} {@link EventEmitter} * returned * from {@link Http}. + * + * ### Example + * + * ``` + * var connection; + * backend.connections.subscribe(c => connection = c); + * http.request('data.json').subscribe(res => res, err => console.log(err))); + * connection.mockError(new Error('error')); + * ``` + * */ mockError(err?: Error) { // Matches XHR semantics