diff options
| author | Misko Hevery | 2012-01-06 18:10:47 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2012-01-10 22:27:00 -0800 | 
| commit | 5143e7bf065a3cbdf8400cf095b653d51bc83b8f (patch) | |
| tree | 980149c365d4cb5586d27975d26366a25ff7be6a /test/InjectorSpec.js | |
| parent | afd25446d23f24872eb20ac79c8fbd2cff203ef0 (diff) | |
| download | angular.js-5143e7bf065a3cbdf8400cf095b653d51bc83b8f.tar.bz2 | |
feat(module): new module loader
Diffstat (limited to 'test/InjectorSpec.js')
| -rw-r--r-- | test/InjectorSpec.js | 41 | 
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([]); +        });        });  | 
