From 9398040a41d0041f949d5b5219eaaf1074cd5699 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 27 Jul 2012 11:01:06 -0700 Subject: test(ngApp): add missing test for [ng-app] bootstrap --- test/AngularSpec.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'test/AngularSpec.js') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 1c0f5f78..0c89a3f2 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -331,6 +331,12 @@ describe('angular', function() { return element.getElementById[id] || []; }, + + querySelectorAll: function(arg) { + return element.querySelectorAll[arg] || []; + }, + + getAttribute: function(name) { return element[name]; } @@ -345,6 +351,14 @@ describe('angular', function() { }); + it('should look for ngApp directive as attr', function() { + var appElement = jqLite('
')[0]; + element.querySelectorAll['[ng-app]'] = [appElement]; + angularInit(element, bootstrap); + expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']); + }); + + it('should look for ngApp directive in id', function() { var appElement = jqLite('')[0]; jqLite(document.body).append(appElement); @@ -355,7 +369,6 @@ describe('angular', function() { it('should look for ngApp directive in className', function() { var appElement = jqLite('')[0]; - element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; } element.querySelectorAll['.ng\\:app'] = [appElement]; angularInit(element, bootstrap); expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']); @@ -364,7 +377,6 @@ describe('angular', function() { it('should look for ngApp directive using querySelectorAll', function() { var appElement = jqLite('')[0]; - element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; } element.querySelectorAll['[ng\\:app]'] = [ appElement ]; angularInit(element, bootstrap); expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']); @@ -380,7 +392,6 @@ describe('angular', function() { it('should bootstrap anonymously', function() { var appElement = jqLite('')[0]; - element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; } element.querySelectorAll['[x-ng-app]'] = [ appElement ]; angularInit(element, bootstrap); expect(bootstrap).toHaveBeenCalledOnceWith(appElement, []); -- cgit v1.2.3