mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
feat(module): new module loader
This commit is contained in:
@@ -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([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user