From fb0996da501e54af78624f08167f24ff1f7d0620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Wed, 19 Mar 2014 00:46:56 -0700 Subject: [PATCH] Added response to whenPOST mock The ```whenPOST``` method should return a response object containing status, response body and headers. If omitted the following error will be thrown: ```Uncaught TypeError: Cannot read property '2' of undefined``` The documentation doesn't make it very clear, so I think it will be appropriate to add it here. --- src/ngMock/angular-mocks.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 02e5432961ca..566d3c43cf4b 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1806,7 +1806,9 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { * * // adds a new phone to the phones array * $httpBackend.whenPOST('/phones').respond(function(method, url, data) { - * phones.push(angular.fromJson(data)); + * var phone = angular.fromJson(data); + * phones.push(phone); + * return [200, phone, {}]; * }); * $httpBackend.whenGET(/^\/templates\//).passThrough(); * //...