Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9398040

Browse files
committed
test(ngApp): add missing test for [ng-app] bootstrap
1 parent d804bbc commit 9398040

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/AngularSpec.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ describe('angular', function() {
331331
return element.getElementById[id] || [];
332332
},
333333

334+
335+
querySelectorAll: function(arg) {
336+
return element.querySelectorAll[arg] || [];
337+
},
338+
339+
334340
getAttribute: function(name) {
335341
return element[name];
336342
}
@@ -345,6 +351,14 @@ describe('angular', function() {
345351
});
346352

347353

354+
it('should look for ngApp directive as attr', function() {
355+
var appElement = jqLite('<div ng-app="ABC"></div>')[0];
356+
element.querySelectorAll['[ng-app]'] = [appElement];
357+
angularInit(element, bootstrap);
358+
expect(bootstrap).toHaveBeenCalledOnceWith(appElement, ['ABC']);
359+
});
360+
361+
348362
it('should look for ngApp directive in id', function() {
349363
var appElement = jqLite('<div id="ng-app" data-ng-app="ABC"></div>')[0];
350364
jqLite(document.body).append(appElement);
@@ -355,7 +369,6 @@ describe('angular', function() {
355369

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

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

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

0 commit comments

Comments
 (0)