Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
test(ngApp): add missing test for [ng-app] bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Aug 30, 2012
1 parent bb9bade commit 4f0be2a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ describe('angular', function() {
return element.getElementById[id] || [];
},


querySelectorAll: function(arg) {
return element.querySelectorAll[arg] || [];
},


getAttribute: function(name) {
return element[name];
}
Expand All @@ -345,6 +351,14 @@ describe('angular', function() {
});


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']);
});


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);
Expand All @@ -355,7 +369,6 @@ describe('angular', function() {

it('should look for ngApp directive in className', function() {
var appElement = jqLite('<div data-ng-app="ABC"></div>')[0];
element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; }
element.querySelectorAll['.ng\\:app'] = [appElement];
angularInit(element, bootstrap);
expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
Expand All @@ -364,7 +377,6 @@ describe('angular', function() {

it('should look for ngApp directive using querySelectorAll', function() {
var appElement = jqLite('<div x-ng-app="ABC"></div>')[0];
element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; }
element.querySelectorAll['[ng\\:app]'] = [ appElement ];
angularInit(element, bootstrap);
expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
Expand All @@ -380,7 +392,6 @@ describe('angular', function() {

it('should bootstrap anonymously', function() {
var appElement = jqLite('<div x-ng-app></div>')[0];
element.querySelectorAll = function(arg) { return element.querySelectorAll[arg] || []; }
element.querySelectorAll['[x-ng-app]'] = [ appElement ];
angularInit(element, bootstrap);
expect(bootstrap).toHaveBeenCalledOnceWith(appElement, []);
Expand Down

0 comments on commit 4f0be2a

Please sign in to comment.