tech(lib upgrade): fixed issue with angular 1.5.8, so can revert revert of upgrade, that is we are no on latest angularjs, #6022

This commit is contained in:
Torkel Ödegaard
2016-09-14 10:45:56 +02:00
parent c594f9f2ad
commit babab7677c
30 changed files with 2866 additions and 1477 deletions

View File

@@ -1,20 +1,20 @@
{
"name": "angular-mocks",
"version": "1.5.3",
"version": "1.5.8",
"license": "MIT",
"main": "./angular-mocks.js",
"ignore": [],
"dependencies": {
"angular": "1.5.3"
"angular": "1.5.8"
},
"homepage": "https://github.com/angular/bower-angular-mocks",
"_release": "1.5.3",
"_release": "1.5.8",
"_resolution": {
"type": "version",
"tag": "v1.5.3",
"commit": "319557fe710cecc11e12c772cc1abb8098d29ccb"
"tag": "v1.5.8",
"commit": "482eefcf6b03057c5fcddb9750e460f458ee3487"
},
"_source": "https://github.com/angular/bower-angular-mocks.git",
"_target": "1.5.3",
"_target": "1.5.8",
"_originalSource": "angular-mocks"
}

21
public/vendor/angular-mocks/LICENSE.md vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Angular
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -20,7 +20,7 @@ You can `require` ngMock modules:
var angular = require('angular');
angular.module('myMod', [
require('angular-animate'),
require('angular-mocks/ngMock')
require('angular-mocks/ngMock'),
require('angular-mocks/ngAnimateMock')
]);
```

View File

@@ -1,9 +1,9 @@
/**
* @license AngularJS v1.5.3
* @license AngularJS v1.5.8
* (c) 2010-2016 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {
(function(window, angular) {
'use strict';
@@ -13,6 +13,7 @@
* @description
*
* Namespace from 'angular-mocks.js' which contains testing related code.
*
*/
angular.mock = {};
@@ -24,7 +25,7 @@ angular.mock = {};
* @description
* This service is a mock implementation of {@link ng.$browser}. It provides fake
* implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr,
* cookies, etc...
* cookies, etc.
*
* The api of this service is the same as that of the real {@link ng.$browser $browser}, except
* that there are several helper methods available which can be used in tests.
@@ -112,19 +113,29 @@ angular.mock.$Browser = function() {
* @param {number=} number of milliseconds to flush. See {@link #defer.now}
*/
self.defer.flush = function(delay) {
var nextTime;
if (angular.isDefined(delay)) {
self.defer.now += delay;
// A delay was passed so compute the next time
nextTime = self.defer.now + delay;
} else {
if (self.deferredFns.length) {
self.defer.now = self.deferredFns[self.deferredFns.length - 1].time;
// No delay was passed so set the next time so that it clears the deferred queue
nextTime = self.deferredFns[self.deferredFns.length - 1].time;
} else {
// No delay passed, but there are no deferred tasks so flush - indicates an error!
throw new Error('No deferred tasks to be flushed');
}
}
while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) {
while (self.deferredFns.length && self.deferredFns[0].time <= nextTime) {
// Increment the time and call the next deferred function
self.defer.now = self.deferredFns[0].time;
self.deferredFns.shift().fn();
}
// Ensure that the current time is correct
self.defer.now = nextTime;
};
self.$$baseHref = '/';
@@ -226,13 +237,13 @@ angular.mock.$ExceptionHandlerProvider = function() {
* @param {string} mode Mode of operation, defaults to `rethrow`.
*
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later
* assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
* {@link ngMock.$log#reset reset()}
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later assertion of
* them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
* {@link ngMock.$log#reset reset()}.
* - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
* is a bug in the application or test, so this mock will make these tests fail.
* For any implementations that expect exceptions to be thrown, the `rethrow` mode
* will also maintain a log of thrown errors.
* is a bug in the application or test, so this mock will make these tests fail. For any
* implementations that expect exceptions to be thrown, the `rethrow` mode will also maintain
* a log of thrown errors in `$exceptionHandler.errors`.
*/
this.mode = function(mode) {
@@ -766,6 +777,8 @@ angular.mock.TzDate.prototype = Date.prototype;
* @description
* Mock implementation of the {@link ng.$animate `$animate`} service. Exposes two additional methods
* for testing animations.
*
* You need to require the `ngAnimateMock` module in your test suite for instance `beforeEach(module('ngAnimateMock'))`
*/
angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
@@ -931,13 +944,10 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
* @name angular.mock.dump
* @description
*
* *NOTE*: this is not an injectable instance, just a globally available function.
* *NOTE*: This is not an injectable instance, just a globally available function.
*
* Method for serializing common angular objects (scope, elements, etc..) into strings, useful for
* debugging.
*
* This method is also available on window, where it can be used to display objects on debug
* console.
* Method for serializing common angular objects (scope, elements, etc..) into strings.
* It is useful for logging objects to the console when debugging.
*
* @param {*} object - any object to turn into string.
* @return {string} a serialized string of the argument
@@ -1003,8 +1013,10 @@ angular.mock.dump = function(object) {
* Fake HTTP backend implementation suitable for unit testing applications that use the
* {@link ng.$http $http service}.
*
* *Note*: For fake HTTP backend implementation suitable for end-to-end testing or backend-less
* <div class="alert alert-info">
* **Note**: For fake HTTP backend implementation suitable for end-to-end testing or backend-less
* development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}.
* </div>
*
* During unit testing, we want our unit tests to run quickly and have no external dependencies so
* we dont want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or
@@ -1328,12 +1340,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
}
// TODO(vojta): change params to: method, url, data, headers, callback
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType) {
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers) {
var xhr = new MockXhr(),
expectation = expectations[0],
wasExpected = false;
xhr.$$events = eventHandlers;
xhr.upload.$$events = uploadEventHandlers;
function prettyPrint(data) {
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
? data
@@ -1393,7 +1408,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
// if $browser specified, we do auto flush all requests
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
} else if (definition.passThrough) {
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers);
} else throw new Error('No response defined !');
return;
}
@@ -1423,12 +1438,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* order to change how a matched request is handled.
*
* - respond
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}`
* ```js
* {function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}
* ```
* The respond method takes a set of static data to be returned or a function that can
* return an array containing response status (number), response data (string), response
* headers (Object), and the text for the status (string). The respond method returns the
* `requestHandler` object for possible overrides.
* return an array containing response status (number), response data (Array|Object|string),
* response headers (Object), and the text for the status (string). The respond method returns
* the `requestHandler` object for possible overrides.
*/
$httpBackend.when = function(method, url, data, headers, keys) {
var definition = new MockHttpExpectation(method, url, data, headers, keys),
@@ -1613,12 +1630,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* order to change how a matched request is handled.
*
* - respond
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}`
* ```
* { function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}
* ```
* The respond method takes a set of static data to be returned or a function that can
* return an array containing response status (number), response data (string), response
* headers (Object), and the text for the status (string). The respond method returns the
* `requestHandler` object for possible overrides.
* return an array containing response status (number), response data (Array|Object|string),
* response headers (Object), and the text for the status (string). The respond method returns
* the `requestHandler` object for possible overrides.
*/
$httpBackend.expect = function(method, url, data, headers, keys) {
var expectation = new MockHttpExpectation(method, url, data, headers, keys),
@@ -1868,6 +1887,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
function MockHttpExpectation(method, url, data, headers, keys) {
function getUrlParams(u) {
var params = u.slice(u.indexOf('?') + 1).split('&');
return params.sort();
}
function compareUrl(u) {
return (url.slice(0, url.indexOf('?')) == u.slice(0, u.indexOf('?')) && getUrlParams(url).join() == getUrlParams(u).join());
}
this.data = data;
this.headers = headers;
@@ -1883,7 +1911,7 @@ function MockHttpExpectation(method, url, data, headers, keys) {
if (!url) return true;
if (angular.isFunction(url.test)) return url.test(u);
if (angular.isFunction(url)) return url(u);
return url == u;
return (url == u || compareUrl(u));
};
this.matchHeaders = function(h) {
@@ -2012,6 +2040,20 @@ function MockXhr() {
};
this.abort = angular.noop;
// This section simulates the events on a real XHR object (and the upload object)
// When we are testing $httpBackend (inside the angular project) we make partial use of this
// but store the events directly ourselves on `$$events`, instead of going through the `addEventListener`
this.$$events = {};
this.addEventListener = function(name, listener) {
if (angular.isUndefined(this.$$events[name])) this.$$events[name] = [];
this.$$events[name].push(listener);
};
this.upload = {
$$events: {},
addEventListener: this.addEventListener
};
}
@@ -2166,9 +2208,15 @@ angular.mock.$RootElementProvider = function() {
angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
return function(expression, locals, later, ident) {
if (later && typeof later === 'object') {
var create = $delegate(expression, locals, true, ident);
angular.extend(create.instance, later);
return create();
var instantiate = $delegate(expression, locals, true, ident);
angular.extend(instantiate.instance, later);
var instance = instantiate();
if (instance !== instantiate.instance) {
angular.extend(instance, later);
}
return instance;
}
return $delegate(expression, locals, later, ident);
};
@@ -2181,8 +2229,8 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
* A service that can be used to create instances of component controllers.
* <div class="alert alert-info">
* Be aware that the controller will be instantiated and attached to the scope as specified in
* the component definition object. That means that you must always provide a `$scope` object
* in the `locals` param.
* the component definition object. If you do not provide a `$scope` object in the `locals` param
* then the helper will create a new isolated scope as a child of `$rootScope`.
* </div>
* @param {string} componentName the name of the component whose controller we want to instantiate
* @param {Object} locals Injection locals for Controller.
@@ -2192,7 +2240,7 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
* @return {Object} Instance of requested controller.
*/
angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
this.$get = ['$controller','$injector', function($controller,$injector) {
this.$get = ['$controller','$injector', '$rootScope', function($controller, $injector, $rootScope) {
return function $componentController(componentName, locals, bindings, ident) {
// get all directives associated to the component name
var directives = $injector.get(componentName + 'Directive');
@@ -2210,6 +2258,9 @@ angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compi
}
// get the info of the component
var directiveInfo = candidateDirectives[0];
// create a scope if needed
locals = locals || {};
locals.$scope = locals.$scope || $rootScope.$new(true);
return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
};
}];
@@ -2231,6 +2282,34 @@ angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compi
*
* <div doc-module-components="ngMock"></div>
*
* @installation
*
* First, download the file:
* * [Google CDN](https://developers.google.com/speed/libraries/devguide#angularjs) e.g.
* `"//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-mocks.js"`
* * [NPM](https://www.npmjs.com/) e.g. `npm install angular-mocks@X.Y.Z`
* * [Bower](http://bower.io) e.g. `bower install angular-mocks#X.Y.Z`
* * [code.angularjs.org](https://code.angularjs.org/) (discouraged for production use) e.g.
* `"//code.angularjs.org/X.Y.Z/angular-mocks.js"`
*
* where X.Y.Z is the AngularJS version you are running.
*
* Then, configure your test runner to load `angular-mocks.js` after `angular.js`.
* This example uses <a href="http://karma-runner.github.io/">Karma</a>:
*
* ```
* config.set({
* files: [
* 'build/angular.js', // and other module files you need
* 'build/angular-mocks.js',
* '<path/to/application/files>',
* '<path/to/spec/files>'
* ]
* });
* ```
*
* Including the `angular-mocks.js` file automatically adds the `ngMock` module, so your tests
* are ready to go!
*/
angular.module('ngMock', ['ng']).provider({
$browser: angular.mock.$BrowserProvider,
@@ -2259,6 +2338,7 @@ angular.module('ngMock', ['ng']).provider({
* the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock.
*/
angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
$provide.value('$httpBackend', angular.injector(['ng']).get('$httpBackend'));
$provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator);
}]);
@@ -2270,8 +2350,10 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of
* applications that use the {@link ng.$http $http service}.
*
* *Note*: For fake http backend implementation suitable for unit testing please see
* <div class="alert alert-info">
* **Note**: For fake http backend implementation suitable for unit testing please see
* {@link ngMock.$httpBackend unit-testing $httpBackend mock}.
* </div>
*
* This implementation can be used to respond with static or dynamic responses via the `when` api
* and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the
@@ -2292,9 +2374,9 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* on the `ngMockE2E` and your application modules and defines the fake backend:
*
* ```js
* myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']);
* var myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']);
* myAppDev.run(function($httpBackend) {
* phones = [{name: 'phone1'}, {name: 'phone2'}];
* var phones = [{name: 'phone1'}, {name: 'phone2'}];
*
* // returns the current list of phones
* $httpBackend.whenGET('/phones').respond(phones);
@@ -2305,12 +2387,74 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* phones.push(phone);
* return [200, phone, {}];
* });
* $httpBackend.whenGET(/^\/templates\//).passThrough();
* $httpBackend.whenGET(/^\/templates\//).passThrough(); // Requests for templare are handled by the real server
* //...
* });
* ```
*
* Afterwards, bootstrap your app with this new module.
*
* ## Example
* <example name="httpbackend-e2e-testing" module="myAppE2E" deps="angular-mocks.js">
* <file name="app.js">
* var myApp = angular.module('myApp', []);
*
* myApp.controller('main', function($http) {
* var ctrl = this;
*
* ctrl.phones = [];
* ctrl.newPhone = {
* name: ''
* };
*
* ctrl.getPhones = function() {
* $http.get('/phones').then(function(response) {
* ctrl.phones = response.data;
* });
* };
*
* ctrl.addPhone = function(phone) {
* $http.post('/phones', phone).then(function() {
* ctrl.newPhone = {name: ''};
* return ctrl.getPhones();
* });
* };
*
* ctrl.getPhones();
* });
* </file>
* <file name="e2e.js">
* var myAppDev = angular.module('myAppE2E', ['myApp', 'ngMockE2E']);
*
* myAppDev.run(function($httpBackend) {
* var phones = [{name: 'phone1'}, {name: 'phone2'}];
*
* // returns the current list of phones
* $httpBackend.whenGET('/phones').respond(phones);
*
* // adds a new phone to the phones array
* $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
* var phone = angular.fromJson(data);
* phones.push(phone);
* return [200, phone, {}];
* });
* });
* </file>
* <file name="index.html">
* <div ng-controller="main as $ctrl">
* <form name="newPhoneForm" ng-submit="$ctrl.addPhone($ctrl.newPhone)">
* <input type="text" ng-model="$ctrl.newPhone.name">
* <input type="submit" value="Add Phone">
* </form>
* <h1>Phones</h1>
* <ul>
* <li ng-repeat="phone in $ctrl.phones">{{phone.name}}</li>
* </ul>
* </div>
* </file>
* </example>
*
*
*/
/**
@@ -2333,11 +2477,13 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* `respond` or `passThrough` again in order to change how a matched request is handled.
*
* - respond
* `{function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}`
* ```
* { function([status,] data[, headers, statusText])
* | function(function(method, url, data, headers, params)}
* ```
* The respond method takes a set of static data to be returned or a function that can return
* an array containing response status (number), response data (string), response headers
* (Object), and the text for the status (string).
* an array containing response status (number), response data (Array|Object|string), response
* headers (Object), and the text for the status (string).
* - passThrough `{function()}` Any request matching a backend definition with
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
* to the server.)
@@ -2791,7 +2937,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
angular.forEach(angular.callbacks, function(val, key) {
delete angular.callbacks[key];
});
angular.callbacks.counter = 0;
angular.callbacks.$$counter = 0;
};
(window.beforeEach || window.setup)(module.$$beforeEach);
@@ -2894,11 +3040,17 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
this.stack = e.stack + '\n' + errorForStack.stack;
if (e.stackArray) this.stackArray = e.stackArray;
};
ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString;
ErrorAddingDeclarationLocationStack.prototype = Error.prototype;
window.inject = angular.mock.inject = function() {
var blockFns = Array.prototype.slice.call(arguments, 0);
var errorForStack = new Error('Declaration Location');
// IE10+ and PhanthomJS do not set stack trace information, until the error is thrown
if (!errorForStack.stack) {
try {
throw errorForStack;
} catch (e) {}
}
return wasInjectorCreated() ? workFn.call(currentSpec) : workFn;
/////////////////////
function workFn() {

View File

@@ -1,10 +1,10 @@
{
"name": "angular-mocks",
"version": "1.5.3",
"version": "1.5.8",
"license": "MIT",
"main": "./angular-mocks.js",
"ignore": [],
"dependencies": {
"angular": "1.5.3"
"angular": "1.5.8"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "angular-mocks",
"version": "1.5.3",
"version": "1.5.8",
"description": "AngularJS mocks for testing",
"main": "angular-mocks.js",
"scripts": {
@@ -23,5 +23,12 @@
"bugs": {
"url": "https://github.com/angular/angular.js/issues"
},
"homepage": "http://angularjs.org"
"homepage": "http://angularjs.org",
"jspm": {
"shim": {
"angular-mocks": {
"deps": ["angular"]
}
}
}
}