@@ -322,7 +322,7 @@ describe('angular', function() {
322
322
323
323
324
324
describe ( 'angularInit' , function ( ) {
325
- var bootstrap ;
325
+ var bootstrapSpy ;
326
326
var element ;
327
327
328
328
beforeEach ( function ( ) {
@@ -341,74 +341,83 @@ describe('angular', function() {
341
341
return element [ name ] ;
342
342
}
343
343
} ;
344
- bootstrap = jasmine . createSpy ( 'bootstrap ' ) ;
344
+ bootstrapSpy = jasmine . createSpy ( 'bootstrapSpy ' ) ;
345
345
} ) ;
346
346
347
347
348
348
it ( 'should do nothing when not found' , function ( ) {
349
- angularInit ( element , bootstrap ) ;
350
- expect ( bootstrap ) . not . toHaveBeenCalled ( ) ;
349
+ angularInit ( element , bootstrapSpy ) ;
350
+ expect ( bootstrapSpy ) . not . toHaveBeenCalled ( ) ;
351
351
} ) ;
352
352
353
353
354
354
it ( 'should look for ngApp directive as attr' , function ( ) {
355
355
var appElement = jqLite ( '<div ng-app="ABC"></div>' ) [ 0 ] ;
356
356
element . querySelectorAll [ '[ng-app]' ] = [ appElement ] ;
357
- angularInit ( element , bootstrap ) ;
358
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
357
+ angularInit ( element , bootstrapSpy ) ;
358
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
359
359
} ) ;
360
360
361
361
362
362
it ( 'should look for ngApp directive in id' , function ( ) {
363
363
var appElement = jqLite ( '<div id="ng-app" data-ng-app="ABC"></div>' ) [ 0 ] ;
364
364
jqLite ( document . body ) . append ( appElement ) ;
365
- angularInit ( element , bootstrap ) ;
366
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
365
+ angularInit ( element , bootstrapSpy ) ;
366
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
367
367
} ) ;
368
368
369
369
370
370
it ( 'should look for ngApp directive in className' , function ( ) {
371
371
var appElement = jqLite ( '<div data-ng-app="ABC"></div>' ) [ 0 ] ;
372
372
element . querySelectorAll [ '.ng\\:app' ] = [ appElement ] ;
373
- angularInit ( element , bootstrap ) ;
374
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
373
+ angularInit ( element , bootstrapSpy ) ;
374
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
375
375
} ) ;
376
376
377
377
378
378
it ( 'should look for ngApp directive using querySelectorAll' , function ( ) {
379
379
var appElement = jqLite ( '<div x-ng-app="ABC"></div>' ) [ 0 ] ;
380
380
element . querySelectorAll [ '[ng\\:app]' ] = [ appElement ] ;
381
- angularInit ( element , bootstrap ) ;
382
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
381
+ angularInit ( element , bootstrapSpy ) ;
382
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
383
383
} ) ;
384
384
385
385
386
386
it ( 'should bootstrap using class name' , function ( ) {
387
387
var appElement = jqLite ( '<div class="ng-app: ABC;"></div>' ) [ 0 ] ;
388
- angularInit ( jqLite ( '<div></div>' ) . append ( appElement ) [ 0 ] , bootstrap ) ;
389
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
388
+ angularInit ( jqLite ( '<div></div>' ) . append ( appElement ) [ 0 ] , bootstrapSpy ) ;
389
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ 'ABC' ] ) ;
390
390
} ) ;
391
391
392
392
393
393
it ( 'should bootstrap anonymously' , function ( ) {
394
394
var appElement = jqLite ( '<div x-ng-app></div>' ) [ 0 ] ;
395
395
element . querySelectorAll [ '[x-ng-app]' ] = [ appElement ] ;
396
- angularInit ( element , bootstrap ) ;
397
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
396
+ angularInit ( element , bootstrapSpy ) ;
397
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
398
398
} ) ;
399
399
400
400
401
401
it ( 'should bootstrap anonymously using class only' , function ( ) {
402
402
var appElement = jqLite ( '<div class="ng-app"></div>' ) [ 0 ] ;
403
- angularInit ( jqLite ( '<div></div>' ) . append ( appElement ) [ 0 ] , bootstrap ) ;
404
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
403
+ angularInit ( jqLite ( '<div></div>' ) . append ( appElement ) [ 0 ] , bootstrapSpy ) ;
404
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
405
405
} ) ;
406
406
407
407
408
408
it ( 'should bootstrap if the annotation is on the root element' , function ( ) {
409
409
var appElement = jqLite ( '<div class="ng-app"></div>' ) [ 0 ] ;
410
- angularInit ( appElement , bootstrap ) ;
411
- expect ( bootstrap ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
410
+ angularInit ( appElement , bootstrapSpy ) ;
411
+ expect ( bootstrapSpy ) . toHaveBeenCalledOnceWith ( appElement , [ ] ) ;
412
+ } ) ;
413
+
414
+
415
+ it ( 'should complain if app module cannot be found' , function ( ) {
416
+ var appElement = jqLite ( '<div ng-app="doesntexist"></div>' ) [ 0 ] ;
417
+
418
+ expect ( function ( ) {
419
+ angularInit ( appElement , bootstrap ) ;
420
+ } ) . toThrow ( 'No module: doesntexist' ) ;
412
421
} ) ;
413
422
} ) ;
414
423
@@ -546,6 +555,17 @@ describe('angular', function() {
546
555
expect ( element . data ( '$injector' ) ) . toBe ( injector ) ;
547
556
dealoc ( element ) ;
548
557
} ) ;
558
+
559
+ it ( "should complain if app module can't be found" , function ( ) {
560
+ var element = jqLite ( '<div>{{1+2}}</div>' ) ;
561
+
562
+ expect ( function ( ) {
563
+ angular . bootstrap ( element , [ 'doesntexist' ] ) ;
564
+ } ) . toThrow ( 'No module: doesntexist' ) ;
565
+
566
+ expect ( element . html ( ) ) . toBe ( '{{1+2}}' ) ;
567
+ dealoc ( element ) ;
568
+ } ) ;
549
569
} ) ;
550
570
551
571
0 commit comments