fix(ngMock): handle cases where injector is created before tests

This caused an exception for people who created an injector before the tests actually began to run. Since the array was initialized only in beforeEach, anyone accessing it before that would throw. This is solved easily but initializing the array immediately.

Closes #10967
This commit is contained in:
Shahar Talmi
2015-02-04 22:42:04 +02:00
parent 966f6d831f
commit 898714df9e
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -2131,7 +2131,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
if (window.jasmine || window.mocha) {
var currentSpec = null,
annotatedFunctions,
annotatedFunctions = [],
isSpecRunning = function() {
return !!currentSpec;
};
+7
View File
@@ -1813,3 +1813,10 @@ describe('ngMockE2E', function() {
});
});
});
describe('make sure that we can create an injector outside of tests', function() {
//since some libraries create custom injectors outside of tests,
//we want to make sure that this is not breaking the internals of
//how we manage annotated function cleanup during tests. See #10967
angular.injector([function($injector) {}]);
});