Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngMock): make matchLatestDefinitionEnabled work #16713

Merged
merged 2 commits into from
Oct 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,20 +1619,20 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {

/**
* @ngdoc method
* @name $httpBackend#matchLatestDefinition
* @name $httpBackend#matchLatestDefinitionEnabled
* @description
* This method can be used to change which mocked responses `$httpBackend` returns, when defining
* them with {@link ngMock.$httpBackend#when $httpBackend.when()} (and shortcut methods).
* By default, `$httpBackend` returns the first definition that matches. When setting
* `$http.matchLatestDefinition(true)`, it will use the last response that matches, i.e. the
* `$http.matchLatestDefinitionEnabled(true)`, it will use the last response that matches, i.e. the
* one that was added last.
*
* ```js
* hb.when('GET', '/url1').respond(200, 'content', {});
* hb.when('GET', '/url1').respond(201, 'another', {});
* hb('GET', '/url1'); // receives "content"
*
* $http.matchLatestDefinition(true)
* $http.matchLatestDefinitionEnabled(true)
* hb('GET', '/url1'); // receives "another"
*
* hb.when('GET', '/url1').respond(201, 'onemore', {});
Expand All @@ -1641,7 +1641,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
*
* This is useful if a you have a default response that is overriden inside specific tests.
*
* Note that different from config methods on providers, `matchLatestDefinition()` can be changed
* Note that different from config methods on providers, `matchLatestDefinitionEnabled()` can be changed
* even when the application is already running.
*
* @param {Boolean=} value value to set, either `true` or `false`. Default is `false`.
Expand All @@ -1650,7 +1650,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* as a getter
*/
$httpBackend.matchLatestDefinitionEnabled = function(value) {
if (isDefined(value)) {
if (angular.isDefined(value)) {
matchLatestDefinition = value;
return this;
} else {
Expand Down Expand Up @@ -2919,21 +2919,21 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
*/
/**
* @ngdoc method
* @name $httpBackend#matchLatestDefinition
* @name $httpBackend#matchLatestDefinitionEnabled
* @module ngMockE2E
* @description
* This method can be used to change which mocked responses `$httpBackend` returns, when defining
* them with {@link ngMock.$httpBackend#when $httpBackend.when()} (and shortcut methods).
* By default, `$httpBackend` returns the first definition that matches. When setting
* `$http.matchLatestDefinition(true)`, it will use the last response that matches, i.e. the
* `$http.matchLatestDefinitionEnabled(true)`, it will use the last response that matches, i.e. the
* one that was added last.
*
* ```js
* hb.when('GET', '/url1').respond(200, 'content', {});
* hb.when('GET', '/url1').respond(201, 'another', {});
* hb('GET', '/url1'); // receives "content"
*
* $http.matchLatestDefinition(true)
* $http.matchLatestDefinitionEnabled(true)
* hb('GET', '/url1'); // receives "another"
*
* hb.when('GET', '/url1').respond(201, 'onemore', {});
Expand All @@ -2942,7 +2942,7 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
*
* This is useful if a you have a default response that is overriden inside specific tests.
*
* Note that different from config methods on providers, `matchLatestDefinition()` can be changed
* Note that different from config methods on providers, `matchLatestDefinitionEnabled()` can be changed
* even when the application is already running.
*
* @param {Boolean=} value value to set, either `true` or `false`. Default is `false`.
Expand Down