mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
feat($injector): print caller name in "unknown provider" errors (when available)
NGEUROPE!!!!! Closes #8135 Closes #9721
This commit is contained in:
committed by
Caitlin Potter
parent
7c6be43e83
commit
013b522c9e
@@ -4,12 +4,14 @@ describe('injector', function() {
|
||||
var providers;
|
||||
var injector;
|
||||
var providerInjector;
|
||||
var controllerProvider;
|
||||
|
||||
beforeEach(module(function($provide, $injector) {
|
||||
beforeEach(module(function($provide, $injector, $controllerProvider) {
|
||||
providers = function(name, factory, annotations) {
|
||||
$provide.factory(name, extend(factory, annotations || {}));
|
||||
};
|
||||
providerInjector = $injector;
|
||||
controllerProvider = $controllerProvider;
|
||||
}));
|
||||
beforeEach(inject(function($injector) {
|
||||
injector = $injector;
|
||||
@@ -74,6 +76,22 @@ describe('injector', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should provide the caller name if given', function(done) {
|
||||
expect(function() {
|
||||
injector.get('idontexist', 'callerName');
|
||||
}).toThrowMinErr("$injector", "unpr", "Unknown provider: idontexistProvider <- idontexist <- callerName");
|
||||
});
|
||||
|
||||
|
||||
it('should provide the caller name for controllers', function(done) {
|
||||
controllerProvider.register('myCtrl', function(idontexist) {});
|
||||
var $controller = injector.get('$controller');
|
||||
expect(function() {
|
||||
$controller('myCtrl', {$scope: {}});
|
||||
}).toThrowMinErr("$injector", "unpr", "Unknown provider: idontexistProvider <- idontexist <- myCtrl");
|
||||
});
|
||||
|
||||
|
||||
it('should not corrupt the cache when an object fails to get instantiated', function() {
|
||||
expect(function() {
|
||||
injector.get('idontexist');
|
||||
|
||||
Reference in New Issue
Block a user