@@ -17,7 +17,7 @@ function itAsync(title, func) {
17
17
} ) ;
18
18
}
19
19
20
- /* global checkConfig, isPromise, loadingClass, errorClass */
20
+ /* global checkConfig, createInjector, isPromise, loadingClass, errorClass */
21
21
describe ( 'deferredBootstrapper' , function ( ) {
22
22
23
23
it ( 'should provide bootstrap function' , function ( ) {
@@ -35,6 +35,29 @@ describe('deferredBootstrapper', function () {
35
35
bodyElement = window . document . body ;
36
36
} ) ;
37
37
38
+ itAsync ( 'should inject $location' , function ( done ) {
39
+ bootstrap ( {
40
+ element : bodyElement ,
41
+ module : APP_NAME ,
42
+ resolve : {
43
+ LOCATION : function ( $http , $q , $location ) {
44
+ var deferred = $q . defer ( ) ;
45
+
46
+ deferred . resolve ( $location ) ;
47
+
48
+ return deferred . promise ;
49
+ }
50
+ }
51
+ } ) ;
52
+
53
+ angular . module ( APP_NAME , [ ] )
54
+ . config ( function ( LOCATION ) {
55
+ expect ( LOCATION ) . toBeDefined ( ) ;
56
+
57
+ done ( ) ;
58
+ } ) ;
59
+ } ) ;
60
+
38
61
itAsync ( 'should resolve with the value returned from the defined constant' , function ( done ) {
39
62
bootstrap ( {
40
63
element : bodyElement ,
@@ -422,6 +445,57 @@ describe('deferredBootstrapper', function () {
422
445
423
446
} ) ;
424
447
448
+ describe ( 'createInjector()' , function ( ) {
449
+ var element ;
450
+
451
+ beforeEach ( function ( ) {
452
+ angular . module ( 'module1' , [ ] ) ;
453
+ angular . module ( 'module2' , [ ] ) ;
454
+ element = angular . element ( '<div></div>' ) ;
455
+ } ) ;
456
+
457
+ it ( 'should create injector with given module as string' , function ( ) {
458
+ // given
459
+ var modules = 'module1' ;
460
+ spyOn ( angular , 'injector' ) . andCallThrough ( ) ;
461
+
462
+ // when
463
+ createInjector ( modules , element ) ;
464
+ var injectorModules = angular . injector . mostRecentCall . args [ 0 ] ;
465
+
466
+ // then
467
+ expect ( injectorModules . indexOf ( 'ng' ) ) . not . toBe ( - 1 ) ;
468
+ expect ( injectorModules . indexOf ( 'module1' ) ) . not . toBe ( - 1 ) ;
469
+ } ) ;
470
+
471
+ it ( 'should create injector with given modules as array' , function ( ) {
472
+ // given
473
+ var modules = [ 'module1' , 'module2' ] ;
474
+ spyOn ( angular , 'injector' ) . andCallThrough ( ) ;
475
+
476
+ // when
477
+ createInjector ( modules , element ) ;
478
+ var injectorModules = angular . injector . mostRecentCall . args [ 0 ] ;
479
+
480
+ // then
481
+ expect ( injectorModules . indexOf ( 'ng' ) ) . not . toBe ( - 1 ) ;
482
+ expect ( injectorModules . indexOf ( 'module1' ) ) . not . toBe ( - 1 ) ;
483
+ expect ( injectorModules . indexOf ( 'module2' ) ) . not . toBe ( - 1 ) ;
484
+ } ) ;
485
+
486
+ it ( 'should create injector with given element' , function ( ) {
487
+ // given
488
+ var modules = 'module1' ;
489
+ spyOn ( angular , 'injector' ) . andCallThrough ( ) ;
490
+
491
+ // when
492
+ createInjector ( modules , element ) ;
493
+
494
+ // then
495
+ expect ( angular . injector ) . toHaveBeenCalledWith ( jasmine . any ( Object ) , element ) ;
496
+ } ) ;
497
+ } ) ;
498
+
425
499
describe ( 'isPromise()' , function ( ) {
426
500
427
501
it ( 'should check if object is a promise' , function ( ) {
0 commit comments