aboutsummaryrefslogtreecommitdiffstats
path: root/test/AngularSpec.js
diff options
context:
space:
mode:
authorIgor Minar2012-07-27 11:29:48 -0700
committerIgor Minar2012-08-30 15:15:11 -0700
commit8114d55a153b1e27ca0bd53aa97a175c925b7c1f (patch)
tree4961fa1dd8573d35ce83c5876bb321aa2653520f /test/AngularSpec.js
parent9398040a41d0041f949d5b5219eaaf1074cd5699 (diff)
downloadangular.js-8114d55a153b1e27ca0bd53aa97a175c925b7c1f.tar.bz2
test(bootstrap): test exception siling during bootstrap
Closes #1018
Diffstat (limited to 'test/AngularSpec.js')
-rw-r--r--test/AngularSpec.js60
1 files changed, 40 insertions, 20 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js
index 0c89a3f2..47670296 100644
--- a/test/AngularSpec.js
+++ b/test/AngularSpec.js
@@ -322,7 +322,7 @@ describe('angular', function() {
describe('angularInit', function() {
- var bootstrap;
+ var bootstrapSpy;
var element;
beforeEach(function() {
@@ -341,74 +341,83 @@ describe('angular', function() {
return element[name];
}
};
- bootstrap = jasmine.createSpy('bootstrap');
+ bootstrapSpy = jasmine.createSpy('bootstrapSpy');
});
it('should do nothing when not found', function() {
- angularInit(element, bootstrap);
- expect(bootstrap).not.toHaveBeenCalled();
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).not.toHaveBeenCalled();
});
it('should look for ngApp directive as attr', function() {
var appElement = jqLite('<div ng-app="ABC"></div>')[0];
element.querySelectorAll['[ng-app]'] = [appElement];
- angularInit(element, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, ['ABC']);
});
it('should look for ngApp directive in id', function() {
var appElement = jqLite('<div id="ng-app" data-ng-app="ABC"></div>')[0];
jqLite(document.body).append(appElement);
- angularInit(element, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, ['ABC']);
});
it('should look for ngApp directive in className', function() {
var appElement = jqLite('<div data-ng-app="ABC"></div>')[0];
element.querySelectorAll['.ng\\:app'] = [appElement];
- angularInit(element, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, ['ABC']);
});
it('should look for ngApp directive using querySelectorAll', function() {
var appElement = jqLite('<div x-ng-app="ABC"></div>')[0];
element.querySelectorAll['[ng\\:app]'] = [ appElement ];
- angularInit(element, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, ['ABC']);
});
it('should bootstrap using class name', function() {
var appElement = jqLite('<div class="ng-app: ABC;"></div>')[0];
- angularInit(jqLite('<div></div>').append(appElement)[0], bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
+ angularInit(jqLite('<div></div>').append(appElement)[0], bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, ['ABC']);
});
it('should bootstrap anonymously', function() {
var appElement = jqLite('<div x-ng-app></div>')[0];
element.querySelectorAll['[x-ng-app]'] = [ appElement ];
- angularInit(element, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, []);
+ angularInit(element, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, []);
});
it('should bootstrap anonymously using class only', function() {
var appElement = jqLite('<div class="ng-app"></div>')[0];
- angularInit(jqLite('<div></div>').append(appElement)[0], bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, []);
+ angularInit(jqLite('<div></div>').append(appElement)[0], bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, []);
});
it('should bootstrap if the annotation is on the root element', function() {
var appElement = jqLite('<div class="ng-app"></div>')[0];
- angularInit(appElement, bootstrap);
- expect(bootstrap).toHaveBeenCalledOnceWith(appElement, []);
+ angularInit(appElement, bootstrapSpy);
+ expect(bootstrapSpy).toHaveBeenCalledOnceWith(appElement, []);
+ });
+
+
+ it('should complain if app module cannot be found', function() {
+ var appElement = jqLite('<div ng-app="doesntexist"></div>')[0];
+
+ expect(function() {
+ angularInit(appElement, bootstrap);
+ }).toThrow('No module: doesntexist');
});
});
@@ -546,6 +555,17 @@ describe('angular', function() {
expect(element.data('$injector')).toBe(injector);
dealoc(element);
});
+
+ it("should complain if app module can't be found", function() {
+ var element = jqLite('<div>{{1+2}}</div>');
+
+ expect(function() {
+ angular.bootstrap(element, ['doesntexist']);
+ }).toThrow('No module: doesntexist');
+
+ expect(element.html()).toBe('{{1+2}}');
+ dealoc(element);
+ });
});