@@ -411,3 +411,95 @@ describe('ng-view', function() {
411
411
} ) ;
412
412
} )
413
413
} ) ;
414
+
415
+ describe ( 'ng-view with configurable template' , function ( ) {
416
+ var element ;
417
+
418
+ beforeEach ( module ( function ( ) {
419
+ return function ( $rootScope , $compile ) {
420
+ element = $compile ( '<ng:view template="template2"></ng:view>' ) ( $rootScope ) ;
421
+ } ;
422
+ } ) ) ;
423
+
424
+ afterEach ( function ( ) {
425
+ dealoc ( element ) ;
426
+ } ) ;
427
+
428
+ it ( 'should use the configured template' , function ( ) {
429
+ module ( function ( $routeProvider ) {
430
+ $routeProvider . when ( '/route1234' , { template : 'myUrl1' , template2 : 'myUrl2' } ) ;
431
+ } ) ;
432
+
433
+ inject ( function ( $rootScope , $compile , $httpBackend , $location , $route ) {
434
+ expect ( element . text ( ) ) . toEqual ( '' ) ;
435
+
436
+ $location . path ( '/route1234' ) ;
437
+ $httpBackend . expect ( 'GET' , 'myUrl2' ) . respond ( '<div>{{1+3}}</div>' ) ;
438
+ $rootScope . $digest ( ) ;
439
+ $httpBackend . flush ( ) ;
440
+ expect ( element . text ( ) ) . toEqual ( '4' ) ;
441
+ } ) ;
442
+ } ) ;
443
+ } ) ;
444
+
445
+ describe ( 'ng-view twice on the same page' , function ( ) {
446
+ var element ;
447
+
448
+ beforeEach ( module ( function ( ) {
449
+ return function ( $rootScope , $compile ) {
450
+ element = $compile ( '<div><div id="view1"><ng:view template="t1"></ng:view></div>_<div id="view2"><ng:view template="t2"></ng:view></div></div>' ) ( $rootScope ) ;
451
+ } ;
452
+ } ) ) ;
453
+
454
+ afterEach ( function ( ) {
455
+ dealoc ( element ) ;
456
+ } ) ;
457
+
458
+ it ( 'should render both views' , function ( ) {
459
+ module ( function ( $routeProvider ) {
460
+ $routeProvider . when ( '/route1234' , { t1 : 'page1' , t2 : 'page2' } ) ;
461
+ } ) ;
462
+
463
+ inject ( function ( $rootScope , $compile , $httpBackend , $location , $route ) {
464
+ expect ( element . text ( ) ) . toEqual ( '_' ) ;
465
+
466
+ $location . path ( '/route1234' ) ;
467
+ $httpBackend . expect ( 'GET' , 'page1' ) . respond ( '<div>{{10+1}}</div>' ) ;
468
+ $httpBackend . expect ( 'GET' , 'page2' ) . respond ( '<div>{{10+2}}</div>' ) ;
469
+ $rootScope . $digest ( ) ;
470
+ $httpBackend . flush ( ) ;
471
+ expect ( element . text ( ) ) . toEqual ( '11_12' ) ;
472
+ } ) ;
473
+ } ) ;
474
+ } ) ;
475
+
476
+ describe ( 'ng-view nested' , function ( ) {
477
+ var element ;
478
+
479
+ beforeEach ( module ( function ( ) {
480
+ return function ( $rootScope , $compile ) {
481
+ element = $compile ( '<ng:view template="layout"></ng:view>' ) ( $rootScope ) ;
482
+ } ;
483
+ } ) ) ;
484
+
485
+ afterEach ( function ( ) {
486
+ dealoc ( element ) ;
487
+ } ) ;
488
+
489
+ it ( 'should render nested views' , function ( ) {
490
+ module ( function ( $routeProvider ) {
491
+ $routeProvider . when ( '/route1234' , { layout : 'layout1' , content : 'content1' } ) ;
492
+ } ) ;
493
+
494
+ inject ( function ( $rootScope , $compile , $httpBackend , $location , $route ) {
495
+ expect ( element . text ( ) ) . toEqual ( '' ) ;
496
+
497
+ $location . path ( '/route1234' ) ;
498
+ $httpBackend . expect ( 'GET' , 'layout1' ) . respond ( 'layout:<ng-view template="content"></ng-view>' ) ;
499
+ $httpBackend . expect ( 'GET' , 'content1' ) . respond ( 'content' ) ;
500
+ $rootScope . $digest ( ) ;
501
+ $httpBackend . flush ( ) ;
502
+ expect ( element . text ( ) ) . toEqual ( 'layout:content' ) ;
503
+ } ) ;
504
+ } ) ;
505
+ } ) ;
0 commit comments