aboutsummaryrefslogtreecommitdiffstats
path: root/test/InjectorSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/InjectorSpec.js')
-rw-r--r--test/InjectorSpec.js41
1 files changed, 34 insertions, 7 deletions
diff --git a/test/InjectorSpec.js b/test/InjectorSpec.js
index 0bce5ffd..3eec169a 100644
--- a/test/InjectorSpec.js
+++ b/test/InjectorSpec.js
@@ -224,22 +224,28 @@ describe('injector', function() {
it('should run symbolic modules', function() {
- var $injector = createInjector(['myModule'], {
- myModule: ['$provide', function(provide) {
- provide.value('a', 'abc');
- }]
- });
+ angularModule('myModule', []).value('a', 'abc');
+ var $injector = createInjector(['myModule']);
expect($injector.get('a')).toEqual('abc');
});
- it('should error on invalid madule name', function() {
+ it('should error on invalid module name', function() {
expect(function() {
createInjector(['IDontExist'], {});
- }).toThrow("Module 'IDontExist' is not defined!");
+ }).toThrow("No module: IDontExist");
});
+ it('should load dependant modules only once', function() {
+ var log = '';
+ angular.module('a', [], function(){ log += 'a'; });
+ angular.module('b', ['a'], function(){ log += 'b'; });
+ angular.module('c', ['a', 'b'], function(){ log += 'c'; });
+ createInjector(['c', 'c']);
+ expect(log).toEqual('abc');
+ });
+
describe('$provide', function() {
describe('value', function() {
it('should configure $provide values', function() {
@@ -247,6 +253,13 @@ describe('injector', function() {
$provide.value('value', 'abc');
}]).get('value')).toEqual('abc');
});
+
+
+ it('should configure a set of values', function() {
+ expect(createInjector([function($provide) {
+ $provide.value({value: Array});
+ }]).get('value')).toEqual(Array);
+ });
});
@@ -256,6 +269,13 @@ describe('injector', function() {
$provide.factory('value', valueFn('abc'));
}]).get('value')).toEqual('abc');
});
+
+
+ it('should configure a set of factories', function() {
+ expect(createInjector([function($provide) {
+ $provide.factory({value: Array});
+ }]).get('value')).toEqual([]);
+ });
});
@@ -279,6 +299,13 @@ describe('injector', function() {
$provide.service('value', Type);
}]).get('value')).toEqual('abc');
});
+
+
+ it('should configure a set of services', function() {
+ expect(createInjector([function($provide) {
+ $provide.service({value: valueFn({$get:Array})});
+ }]).get('value')).toEqual([]);
+ });
});