angularjs-rails 1.5.0 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/angularjs-rails/version.rb +2 -2
- data/vendor/assets/javascripts/angular-animate.js +82 -56
- data/vendor/assets/javascripts/angular-aria.js +12 -5
- data/vendor/assets/javascripts/angular-cookies.js +2 -2
- data/vendor/assets/javascripts/angular-loader.js +5 -5
- data/vendor/assets/javascripts/angular-message-format.js +2 -2
- data/vendor/assets/javascripts/angular-messages.js +63 -28
- data/vendor/assets/javascripts/angular-mocks.js +280 -116
- data/vendor/assets/javascripts/angular-parse-ext.js +1271 -0
- data/vendor/assets/javascripts/angular-resource.js +3 -3
- data/vendor/assets/javascripts/angular-route.js +16 -7
- data/vendor/assets/javascripts/angular-sanitize.js +4 -4
- data/vendor/assets/javascripts/angular-scenario.js +882 -442
- data/vendor/assets/javascripts/angular-touch.js +2 -2
- data/vendor/assets/javascripts/angular.js +871 -431
- data/vendor/assets/javascripts/unstable/angular2-polyfills.js +1046 -1832
- data/vendor/assets/javascripts/unstable/angular2.js +22044 -18291
- metadata +7 -6
@@ -1,9 +1,9 @@
|
|
1
1
|
/**
|
2
|
-
* @license AngularJS v1.5.
|
2
|
+
* @license AngularJS v1.5.5
|
3
3
|
* (c) 2010-2016 Google, Inc. http://angularjs.org
|
4
4
|
* License: MIT
|
5
5
|
*/
|
6
|
-
(function(window, angular
|
6
|
+
(function(window, angular) {
|
7
7
|
|
8
8
|
'use strict';
|
9
9
|
|
@@ -134,12 +134,12 @@ angular.mock.$Browser = function() {
|
|
134
134
|
};
|
135
135
|
angular.mock.$Browser.prototype = {
|
136
136
|
|
137
|
-
/**
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
137
|
+
/**
|
138
|
+
* @name $browser#poll
|
139
|
+
*
|
140
|
+
* @description
|
141
|
+
* run all fns in pollFns
|
142
|
+
*/
|
143
143
|
poll: function poll() {
|
144
144
|
angular.forEach(this.pollFns, function(pollFn) {
|
145
145
|
pollFn();
|
@@ -552,7 +552,7 @@ angular.mock.$IntervalProvider = function() {
|
|
552
552
|
* This directive should go inside the anonymous function but a bug in JSHint means that it would
|
553
553
|
* not be enacted early enough to prevent the warning.
|
554
554
|
*/
|
555
|
-
var R_ISO8061_STR = /^(
|
555
|
+
var R_ISO8061_STR = /^(-?\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
|
556
556
|
|
557
557
|
function jsonStringToDate(string) {
|
558
558
|
var match;
|
@@ -578,7 +578,7 @@ function toInt(str) {
|
|
578
578
|
return parseInt(str, 10);
|
579
579
|
}
|
580
580
|
|
581
|
-
function
|
581
|
+
function padNumberInMock(num, digits, trim) {
|
582
582
|
var neg = '';
|
583
583
|
if (num < 0) {
|
584
584
|
neg = '-';
|
@@ -727,13 +727,13 @@ angular.mock.TzDate = function(offset, timestamp) {
|
|
727
727
|
// provide this method only on browsers that already have it
|
728
728
|
if (self.toISOString) {
|
729
729
|
self.toISOString = function() {
|
730
|
-
return
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
730
|
+
return padNumberInMock(self.origDate.getUTCFullYear(), 4) + '-' +
|
731
|
+
padNumberInMock(self.origDate.getUTCMonth() + 1, 2) + '-' +
|
732
|
+
padNumberInMock(self.origDate.getUTCDate(), 2) + 'T' +
|
733
|
+
padNumberInMock(self.origDate.getUTCHours(), 2) + ':' +
|
734
|
+
padNumberInMock(self.origDate.getUTCMinutes(), 2) + ':' +
|
735
|
+
padNumberInMock(self.origDate.getUTCSeconds(), 2) + '.' +
|
736
|
+
padNumberInMock(self.origDate.getUTCMilliseconds(), 3) + 'Z';
|
737
737
|
};
|
738
738
|
}
|
739
739
|
|
@@ -1328,11 +1328,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
1328
1328
|
}
|
1329
1329
|
|
1330
1330
|
// TODO(vojta): change params to: method, url, data, headers, callback
|
1331
|
-
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
|
1331
|
+
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers) {
|
1332
|
+
|
1332
1333
|
var xhr = new MockXhr(),
|
1333
1334
|
expectation = expectations[0],
|
1334
1335
|
wasExpected = false;
|
1335
1336
|
|
1337
|
+
xhr.$$events = eventHandlers;
|
1338
|
+
xhr.upload.$$events = uploadEventHandlers;
|
1339
|
+
|
1336
1340
|
function prettyPrint(data) {
|
1337
1341
|
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
|
1338
1342
|
? data
|
@@ -1392,7 +1396,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
1392
1396
|
// if $browser specified, we do auto flush all requests
|
1393
1397
|
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
|
1394
1398
|
} else if (definition.passThrough) {
|
1395
|
-
$delegate(method, url, data, callback, headers, timeout, withCredentials);
|
1399
|
+
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
|
1396
1400
|
} else throw new Error('No response defined !');
|
1397
1401
|
return;
|
1398
1402
|
}
|
@@ -1422,12 +1426,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
1422
1426
|
* order to change how a matched request is handled.
|
1423
1427
|
*
|
1424
1428
|
* - respond –
|
1425
|
-
*
|
1426
|
-
*
|
1429
|
+
* ```js
|
1430
|
+
* {function([status,] data[, headers, statusText])
|
1431
|
+
* | function(function(method, url, data, headers, params)}
|
1432
|
+
* ```
|
1427
1433
|
* – The respond method takes a set of static data to be returned or a function that can
|
1428
|
-
* return an array containing response status (number), response data (string),
|
1429
|
-
* headers (Object), and the text for the status (string). The respond method returns
|
1430
|
-
* `requestHandler` object for possible overrides.
|
1434
|
+
* return an array containing response status (number), response data (Array|Object|string),
|
1435
|
+
* response headers (Object), and the text for the status (string). The respond method returns
|
1436
|
+
* the `requestHandler` object for possible overrides.
|
1431
1437
|
*/
|
1432
1438
|
$httpBackend.when = function(method, url, data, headers, keys) {
|
1433
1439
|
var definition = new MockHttpExpectation(method, url, data, headers, keys),
|
@@ -1612,12 +1618,14 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
|
1612
1618
|
* order to change how a matched request is handled.
|
1613
1619
|
*
|
1614
1620
|
* - respond –
|
1615
|
-
*
|
1616
|
-
*
|
1621
|
+
* ```
|
1622
|
+
* { function([status,] data[, headers, statusText])
|
1623
|
+
* | function(function(method, url, data, headers, params)}
|
1624
|
+
* ```
|
1617
1625
|
* – The respond method takes a set of static data to be returned or a function that can
|
1618
|
-
* return an array containing response status (number), response data (string),
|
1619
|
-
* headers (Object), and the text for the status (string). The respond method returns
|
1620
|
-
* `requestHandler` object for possible overrides.
|
1626
|
+
* return an array containing response status (number), response data (Array|Object|string),
|
1627
|
+
* response headers (Object), and the text for the status (string). The respond method returns
|
1628
|
+
* the `requestHandler` object for possible overrides.
|
1621
1629
|
*/
|
1622
1630
|
$httpBackend.expect = function(method, url, data, headers, keys) {
|
1623
1631
|
var expectation = new MockHttpExpectation(method, url, data, headers, keys),
|
@@ -2011,6 +2019,20 @@ function MockXhr() {
|
|
2011
2019
|
};
|
2012
2020
|
|
2013
2021
|
this.abort = angular.noop;
|
2022
|
+
|
2023
|
+
// This section simulates the events on a real XHR object (and the upload object)
|
2024
|
+
// When we are testing $httpBackend (inside the angular project) we make partial use of this
|
2025
|
+
// but store the events directly ourselves on `$$events`, instead of going through the `addEventListener`
|
2026
|
+
this.$$events = {};
|
2027
|
+
this.addEventListener = function(name, listener) {
|
2028
|
+
if (angular.isUndefined(this.$$events[name])) this.$$events[name] = [];
|
2029
|
+
this.$$events[name].push(listener);
|
2030
|
+
};
|
2031
|
+
|
2032
|
+
this.upload = {
|
2033
|
+
$$events: {},
|
2034
|
+
addEventListener: this.addEventListener
|
2035
|
+
};
|
2014
2036
|
}
|
2015
2037
|
|
2016
2038
|
|
@@ -2095,10 +2117,12 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
|
|
2095
2117
|
/**
|
2096
2118
|
*
|
2097
2119
|
*/
|
2120
|
+
var originalRootElement;
|
2098
2121
|
angular.mock.$RootElementProvider = function() {
|
2099
|
-
this.$get = function() {
|
2100
|
-
|
2101
|
-
|
2122
|
+
this.$get = ['$injector', function($injector) {
|
2123
|
+
originalRootElement = angular.element('<div ng-app></div>').data('$injector', $injector);
|
2124
|
+
return originalRootElement;
|
2125
|
+
}];
|
2102
2126
|
};
|
2103
2127
|
|
2104
2128
|
/**
|
@@ -2127,7 +2151,7 @@ angular.mock.$RootElementProvider = function() {
|
|
2127
2151
|
*
|
2128
2152
|
* myMod.controller('MyDirectiveController', ['$log', function($log) {
|
2129
2153
|
* $log.info(this.name);
|
2130
|
-
* })
|
2154
|
+
* }]);
|
2131
2155
|
*
|
2132
2156
|
*
|
2133
2157
|
* // In a test ...
|
@@ -2137,7 +2161,7 @@ angular.mock.$RootElementProvider = function() {
|
|
2137
2161
|
* var ctrl = $controller('MyDirectiveController', { /* no locals */ }, { name: 'Clark Kent' });
|
2138
2162
|
* expect(ctrl.name).toEqual('Clark Kent');
|
2139
2163
|
* expect($log.info.logs).toEqual(['Clark Kent']);
|
2140
|
-
* });
|
2164
|
+
* }));
|
2141
2165
|
* });
|
2142
2166
|
*
|
2143
2167
|
* ```
|
@@ -2178,8 +2202,8 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
|
|
2178
2202
|
* A service that can be used to create instances of component controllers.
|
2179
2203
|
* <div class="alert alert-info">
|
2180
2204
|
* Be aware that the controller will be instantiated and attached to the scope as specified in
|
2181
|
-
* the component definition object.
|
2182
|
-
*
|
2205
|
+
* the component definition object. If you do not provide a `$scope` object in the `locals` param
|
2206
|
+
* then the helper will create a new isolated scope as a child of `$rootScope`.
|
2183
2207
|
* </div>
|
2184
2208
|
* @param {string} componentName the name of the component whose controller we want to instantiate
|
2185
2209
|
* @param {Object} locals Injection locals for Controller.
|
@@ -2189,29 +2213,30 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
|
|
2189
2213
|
* @return {Object} Instance of requested controller.
|
2190
2214
|
*/
|
2191
2215
|
angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2216
|
+
this.$get = ['$controller','$injector', '$rootScope', function($controller, $injector, $rootScope) {
|
2217
|
+
return function $componentController(componentName, locals, bindings, ident) {
|
2218
|
+
// get all directives associated to the component name
|
2219
|
+
var directives = $injector.get(componentName + 'Directive');
|
2220
|
+
// look for those directives that are components
|
2221
|
+
var candidateDirectives = directives.filter(function(directiveInfo) {
|
2222
|
+
// components have controller, controllerAs and restrict:'E'
|
2223
|
+
return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict === 'E';
|
2224
|
+
});
|
2225
|
+
// check if valid directives found
|
2226
|
+
if (candidateDirectives.length === 0) {
|
2227
|
+
throw new Error('No component found');
|
2228
|
+
}
|
2229
|
+
if (candidateDirectives.length > 1) {
|
2230
|
+
throw new Error('Too many components found');
|
2231
|
+
}
|
2232
|
+
// get the info of the component
|
2233
|
+
var directiveInfo = candidateDirectives[0];
|
2234
|
+
// create a scope if needed
|
2235
|
+
locals = locals || {};
|
2236
|
+
locals.$scope = locals.$scope || $rootScope.$new(true);
|
2237
|
+
return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
|
2238
|
+
};
|
2239
|
+
}];
|
2215
2240
|
}];
|
2216
2241
|
|
2217
2242
|
|
@@ -2332,11 +2357,13 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
|
2332
2357
|
* `respond` or `passThrough` again in order to change how a matched request is handled.
|
2333
2358
|
*
|
2334
2359
|
* - respond –
|
2335
|
-
*
|
2336
|
-
*
|
2360
|
+
* ```
|
2361
|
+
* { function([status,] data[, headers, statusText])
|
2362
|
+
* | function(function(method, url, data, headers, params)}
|
2363
|
+
* ```
|
2337
2364
|
* – The respond method takes a set of static data to be returned or a function that can return
|
2338
|
-
* an array containing response status (number), response data (string), response
|
2339
|
-
* (Object), and the text for the status (string).
|
2365
|
+
* an array containing response status (number), response data (Array|Object|string), response
|
2366
|
+
* headers (Object), and the text for the status (string).
|
2340
2367
|
* - passThrough – `{function()}` – Any request matching a backend definition with
|
2341
2368
|
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
|
2342
2369
|
* to the server.)
|
@@ -2567,11 +2594,16 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
|
|
2567
2594
|
}];
|
2568
2595
|
|
2569
2596
|
|
2570
|
-
|
2597
|
+
!(function(jasmineOrMocha) {
|
2598
|
+
|
2599
|
+
if (!jasmineOrMocha) {
|
2600
|
+
return;
|
2601
|
+
}
|
2571
2602
|
|
2572
2603
|
var currentSpec = null,
|
2604
|
+
injectorState = new InjectorState(),
|
2573
2605
|
annotatedFunctions = [],
|
2574
|
-
|
2606
|
+
wasInjectorCreated = function() {
|
2575
2607
|
return !!currentSpec;
|
2576
2608
|
};
|
2577
2609
|
|
@@ -2583,48 +2615,6 @@ if (window.jasmine || window.mocha) {
|
|
2583
2615
|
return angular.mock.$$annotate.apply(this, arguments);
|
2584
2616
|
};
|
2585
2617
|
|
2586
|
-
|
2587
|
-
(window.beforeEach || window.setup)(function() {
|
2588
|
-
annotatedFunctions = [];
|
2589
|
-
currentSpec = this;
|
2590
|
-
});
|
2591
|
-
|
2592
|
-
(window.afterEach || window.teardown)(function() {
|
2593
|
-
var injector = currentSpec.$injector;
|
2594
|
-
|
2595
|
-
annotatedFunctions.forEach(function(fn) {
|
2596
|
-
delete fn.$inject;
|
2597
|
-
});
|
2598
|
-
|
2599
|
-
angular.forEach(currentSpec.$modules, function(module) {
|
2600
|
-
if (module && module.$$hashKey) {
|
2601
|
-
module.$$hashKey = undefined;
|
2602
|
-
}
|
2603
|
-
});
|
2604
|
-
|
2605
|
-
currentSpec.$injector = null;
|
2606
|
-
currentSpec.$modules = null;
|
2607
|
-
currentSpec.$providerInjector = null;
|
2608
|
-
currentSpec = null;
|
2609
|
-
|
2610
|
-
if (injector) {
|
2611
|
-
injector.get('$rootElement').off();
|
2612
|
-
injector.get('$rootScope').$destroy();
|
2613
|
-
}
|
2614
|
-
|
2615
|
-
// clean up jquery's fragment cache
|
2616
|
-
angular.forEach(angular.element.fragments, function(val, key) {
|
2617
|
-
delete angular.element.fragments[key];
|
2618
|
-
});
|
2619
|
-
|
2620
|
-
MockXhr.$$lastInstance = null;
|
2621
|
-
|
2622
|
-
angular.forEach(angular.callbacks, function(val, key) {
|
2623
|
-
delete angular.callbacks[key];
|
2624
|
-
});
|
2625
|
-
angular.callbacks.counter = 0;
|
2626
|
-
});
|
2627
|
-
|
2628
2618
|
/**
|
2629
2619
|
* @ngdoc function
|
2630
2620
|
* @name angular.mock.module
|
@@ -2645,9 +2635,9 @@ if (window.jasmine || window.mocha) {
|
|
2645
2635
|
* {@link auto.$provide $provide}.value, the key being the string name (or token) to associate
|
2646
2636
|
* with the value on the injector.
|
2647
2637
|
*/
|
2648
|
-
window.module = angular.mock.module = function() {
|
2638
|
+
var module = window.module = angular.mock.module = function() {
|
2649
2639
|
var moduleFns = Array.prototype.slice.call(arguments, 0);
|
2650
|
-
return
|
2640
|
+
return wasInjectorCreated() ? workFn() : workFn;
|
2651
2641
|
/////////////////////
|
2652
2642
|
function workFn() {
|
2653
2643
|
if (currentSpec.$injector) {
|
@@ -2656,11 +2646,11 @@ if (window.jasmine || window.mocha) {
|
|
2656
2646
|
var fn, modules = currentSpec.$modules || (currentSpec.$modules = []);
|
2657
2647
|
angular.forEach(moduleFns, function(module) {
|
2658
2648
|
if (angular.isObject(module) && !angular.isArray(module)) {
|
2659
|
-
fn = function($provide) {
|
2649
|
+
fn = ['$provide', function($provide) {
|
2660
2650
|
angular.forEach(module, function(value, key) {
|
2661
2651
|
$provide.value(key, value);
|
2662
2652
|
});
|
2663
|
-
};
|
2653
|
+
}];
|
2664
2654
|
} else {
|
2665
2655
|
fn = module;
|
2666
2656
|
}
|
@@ -2674,6 +2664,165 @@ if (window.jasmine || window.mocha) {
|
|
2674
2664
|
}
|
2675
2665
|
};
|
2676
2666
|
|
2667
|
+
module.$$beforeAllHook = (window.before || window.beforeAll);
|
2668
|
+
module.$$afterAllHook = (window.after || window.afterAll);
|
2669
|
+
|
2670
|
+
// purely for testing ngMock itself
|
2671
|
+
module.$$currentSpec = function(to) {
|
2672
|
+
if (arguments.length === 0) return to;
|
2673
|
+
currentSpec = to;
|
2674
|
+
};
|
2675
|
+
|
2676
|
+
/**
|
2677
|
+
* @ngdoc function
|
2678
|
+
* @name angular.mock.module.sharedInjector
|
2679
|
+
* @description
|
2680
|
+
*
|
2681
|
+
* *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha
|
2682
|
+
*
|
2683
|
+
* This function ensures a single injector will be used for all tests in a given describe context.
|
2684
|
+
* This contrasts with the default behaviour where a new injector is created per test case.
|
2685
|
+
*
|
2686
|
+
* Use sharedInjector when you want to take advantage of Jasmine's `beforeAll()`, or mocha's
|
2687
|
+
* `before()` methods. Call `module.sharedInjector()` before you setup any other hooks that
|
2688
|
+
* will create (i.e call `module()`) or use (i.e call `inject()`) the injector.
|
2689
|
+
*
|
2690
|
+
* You cannot call `sharedInjector()` from within a context already using `sharedInjector()`.
|
2691
|
+
*
|
2692
|
+
* ## Example
|
2693
|
+
*
|
2694
|
+
* Typically beforeAll is used to make many assertions about a single operation. This can
|
2695
|
+
* cut down test run-time as the test setup doesn't need to be re-run, and enabling focussed
|
2696
|
+
* tests each with a single assertion.
|
2697
|
+
*
|
2698
|
+
* ```js
|
2699
|
+
* describe("Deep Thought", function() {
|
2700
|
+
*
|
2701
|
+
* module.sharedInjector();
|
2702
|
+
*
|
2703
|
+
* beforeAll(module("UltimateQuestion"));
|
2704
|
+
*
|
2705
|
+
* beforeAll(inject(function(DeepThought) {
|
2706
|
+
* expect(DeepThought.answer).toBeUndefined();
|
2707
|
+
* DeepThought.generateAnswer();
|
2708
|
+
* }));
|
2709
|
+
*
|
2710
|
+
* it("has calculated the answer correctly", inject(function(DeepThought) {
|
2711
|
+
* // Because of sharedInjector, we have access to the instance of the DeepThought service
|
2712
|
+
* // that was provided to the beforeAll() hook. Therefore we can test the generated answer
|
2713
|
+
* expect(DeepThought.answer).toBe(42);
|
2714
|
+
* }));
|
2715
|
+
*
|
2716
|
+
* it("has calculated the answer within the expected time", inject(function(DeepThought) {
|
2717
|
+
* expect(DeepThought.runTimeMillennia).toBeLessThan(8000);
|
2718
|
+
* }));
|
2719
|
+
*
|
2720
|
+
* it("has double checked the answer", inject(function(DeepThought) {
|
2721
|
+
* expect(DeepThought.absolutelySureItIsTheRightAnswer).toBe(true);
|
2722
|
+
* }));
|
2723
|
+
*
|
2724
|
+
* });
|
2725
|
+
*
|
2726
|
+
* ```
|
2727
|
+
*/
|
2728
|
+
module.sharedInjector = function() {
|
2729
|
+
if (!(module.$$beforeAllHook && module.$$afterAllHook)) {
|
2730
|
+
throw Error("sharedInjector() cannot be used unless your test runner defines beforeAll/afterAll");
|
2731
|
+
}
|
2732
|
+
|
2733
|
+
var initialized = false;
|
2734
|
+
|
2735
|
+
module.$$beforeAllHook(function() {
|
2736
|
+
if (injectorState.shared) {
|
2737
|
+
injectorState.sharedError = Error("sharedInjector() cannot be called inside a context that has already called sharedInjector()");
|
2738
|
+
throw injectorState.sharedError;
|
2739
|
+
}
|
2740
|
+
initialized = true;
|
2741
|
+
currentSpec = this;
|
2742
|
+
injectorState.shared = true;
|
2743
|
+
});
|
2744
|
+
|
2745
|
+
module.$$afterAllHook(function() {
|
2746
|
+
if (initialized) {
|
2747
|
+
injectorState = new InjectorState();
|
2748
|
+
module.$$cleanup();
|
2749
|
+
} else {
|
2750
|
+
injectorState.sharedError = null;
|
2751
|
+
}
|
2752
|
+
});
|
2753
|
+
};
|
2754
|
+
|
2755
|
+
module.$$beforeEach = function() {
|
2756
|
+
if (injectorState.shared && currentSpec && currentSpec != this) {
|
2757
|
+
var state = currentSpec;
|
2758
|
+
currentSpec = this;
|
2759
|
+
angular.forEach(["$injector","$modules","$providerInjector", "$injectorStrict"], function(k) {
|
2760
|
+
currentSpec[k] = state[k];
|
2761
|
+
state[k] = null;
|
2762
|
+
});
|
2763
|
+
} else {
|
2764
|
+
currentSpec = this;
|
2765
|
+
originalRootElement = null;
|
2766
|
+
annotatedFunctions = [];
|
2767
|
+
}
|
2768
|
+
};
|
2769
|
+
|
2770
|
+
module.$$afterEach = function() {
|
2771
|
+
if (injectorState.cleanupAfterEach()) {
|
2772
|
+
module.$$cleanup();
|
2773
|
+
}
|
2774
|
+
};
|
2775
|
+
|
2776
|
+
module.$$cleanup = function() {
|
2777
|
+
var injector = currentSpec.$injector;
|
2778
|
+
|
2779
|
+
annotatedFunctions.forEach(function(fn) {
|
2780
|
+
delete fn.$inject;
|
2781
|
+
});
|
2782
|
+
|
2783
|
+
angular.forEach(currentSpec.$modules, function(module) {
|
2784
|
+
if (module && module.$$hashKey) {
|
2785
|
+
module.$$hashKey = undefined;
|
2786
|
+
}
|
2787
|
+
});
|
2788
|
+
|
2789
|
+
currentSpec.$injector = null;
|
2790
|
+
currentSpec.$modules = null;
|
2791
|
+
currentSpec.$providerInjector = null;
|
2792
|
+
currentSpec = null;
|
2793
|
+
|
2794
|
+
if (injector) {
|
2795
|
+
// Ensure `$rootElement` is instantiated, before checking `originalRootElement`
|
2796
|
+
var $rootElement = injector.get('$rootElement');
|
2797
|
+
var rootNode = $rootElement && $rootElement[0];
|
2798
|
+
var cleanUpNodes = !originalRootElement ? [] : [originalRootElement[0]];
|
2799
|
+
if (rootNode && (!originalRootElement || rootNode !== originalRootElement[0])) {
|
2800
|
+
cleanUpNodes.push(rootNode);
|
2801
|
+
}
|
2802
|
+
angular.element.cleanData(cleanUpNodes);
|
2803
|
+
|
2804
|
+
// Ensure `$destroy()` is available, before calling it
|
2805
|
+
// (a mocked `$rootScope` might not implement it (or not even be an object at all))
|
2806
|
+
var $rootScope = injector.get('$rootScope');
|
2807
|
+
if ($rootScope && $rootScope.$destroy) $rootScope.$destroy();
|
2808
|
+
}
|
2809
|
+
|
2810
|
+
// clean up jquery's fragment cache
|
2811
|
+
angular.forEach(angular.element.fragments, function(val, key) {
|
2812
|
+
delete angular.element.fragments[key];
|
2813
|
+
});
|
2814
|
+
|
2815
|
+
MockXhr.$$lastInstance = null;
|
2816
|
+
|
2817
|
+
angular.forEach(angular.callbacks, function(val, key) {
|
2818
|
+
delete angular.callbacks[key];
|
2819
|
+
});
|
2820
|
+
angular.callbacks.counter = 0;
|
2821
|
+
};
|
2822
|
+
|
2823
|
+
(window.beforeEach || window.setup)(module.$$beforeEach);
|
2824
|
+
(window.afterEach || window.teardown)(module.$$afterEach);
|
2825
|
+
|
2677
2826
|
/**
|
2678
2827
|
* @ngdoc function
|
2679
2828
|
* @name angular.mock.inject
|
@@ -2776,14 +2925,20 @@ if (window.jasmine || window.mocha) {
|
|
2776
2925
|
window.inject = angular.mock.inject = function() {
|
2777
2926
|
var blockFns = Array.prototype.slice.call(arguments, 0);
|
2778
2927
|
var errorForStack = new Error('Declaration Location');
|
2779
|
-
|
2928
|
+
// IE10+ and PhanthomJS do not set stack trace information, until the error is thrown
|
2929
|
+
if (!errorForStack.stack) {
|
2930
|
+
try {
|
2931
|
+
throw errorForStack;
|
2932
|
+
} catch (e) {}
|
2933
|
+
}
|
2934
|
+
return wasInjectorCreated() ? workFn.call(currentSpec) : workFn;
|
2780
2935
|
/////////////////////
|
2781
2936
|
function workFn() {
|
2782
2937
|
var modules = currentSpec.$modules || [];
|
2783
2938
|
var strictDi = !!currentSpec.$injectorStrict;
|
2784
|
-
modules.unshift(function($injector) {
|
2939
|
+
modules.unshift(['$injector', function($injector) {
|
2785
2940
|
currentSpec.$providerInjector = $injector;
|
2786
|
-
});
|
2941
|
+
}]);
|
2787
2942
|
modules.unshift('ngMock');
|
2788
2943
|
modules.unshift('ng');
|
2789
2944
|
var injector = currentSpec.$injector;
|
@@ -2824,7 +2979,7 @@ if (window.jasmine || window.mocha) {
|
|
2824
2979
|
|
2825
2980
|
angular.mock.inject.strictDi = function(value) {
|
2826
2981
|
value = arguments.length ? !!value : true;
|
2827
|
-
return
|
2982
|
+
return wasInjectorCreated() ? workFn() : workFn;
|
2828
2983
|
|
2829
2984
|
function workFn() {
|
2830
2985
|
if (value !== currentSpec.$injectorStrict) {
|
@@ -2836,7 +2991,16 @@ if (window.jasmine || window.mocha) {
|
|
2836
2991
|
}
|
2837
2992
|
}
|
2838
2993
|
};
|
2839
|
-
|
2994
|
+
|
2995
|
+
function InjectorState() {
|
2996
|
+
this.shared = false;
|
2997
|
+
this.sharedError = null;
|
2998
|
+
|
2999
|
+
this.cleanupAfterEach = function() {
|
3000
|
+
return !this.shared || this.sharedError;
|
3001
|
+
};
|
3002
|
+
}
|
3003
|
+
})(window.jasmine || window.mocha);
|
2840
3004
|
|
2841
3005
|
|
2842
3006
|
})(window, window.angular);
|