@@ -647,4 +647,113 @@ describe('tabs', function() {
647
647
expect ( contents . eq ( 2 ) . text ( ) . trim ( ) ) . toEqual ( '3,4,5,' ) ;
648
648
} ) ) ;
649
649
} ) ;
650
+
651
+ //https://github.com/angular-ui/bootstrap/issues/783
652
+ describe ( 'nested tabs' , function ( ) {
653
+ var elm ;
654
+ it ( 'should render without errors' , inject ( function ( $compile , $rootScope ) {
655
+ var scope = $rootScope . $new ( ) ;
656
+ elm = $compile ( [
657
+ '<div>' ,
658
+ ' <tabset>' ,
659
+ ' <tab heading="Tab 1">' ,
660
+ ' <tabset>' ,
661
+ ' <tab heading="Tab 1A">' ,
662
+ ' </tab>' ,
663
+ ' </tabset>' ,
664
+ ' </tab>' ,
665
+ ' <tab heading="Tab 2">' ,
666
+ ' <tabset>' ,
667
+ ' <tab heading="Tab 2A">' ,
668
+ ' </tab>' ,
669
+ ' </tabset>' ,
670
+ ' </tab>' ,
671
+ ' </tabset>' ,
672
+ '</div>'
673
+ ] . join ( '\n' ) ) ( scope ) ;
674
+ scope . $apply ( ) ;
675
+
676
+ // 1 outside tabset, 2 nested tabsets
677
+ expect ( elm . find ( '.tabbable' ) . length ) . toEqual ( 3 ) ;
678
+ } ) ) ;
679
+
680
+ it ( 'should render with the correct scopes' , inject ( function ( $compile , $rootScope ) {
681
+ var scope = $rootScope . $new ( ) ;
682
+ scope . tab1Text = 'abc' ;
683
+ scope . tab1aText = '123' ;
684
+ scope . tab1aHead = '123' ;
685
+ scope . tab2aaText = '456' ;
686
+ elm = $compile ( [
687
+ '<div>' ,
688
+ ' <tabset>' ,
689
+ ' <tab heading="Tab 1">' ,
690
+ ' <tabset>' ,
691
+ ' <tab heading="{{ tab1aHead }}">' ,
692
+ ' {{ tab1aText }}' ,
693
+ ' </tab>' ,
694
+ ' </tabset>' ,
695
+ ' <span class="tab-1">{{ tab1Text }}</span>' ,
696
+ ' </tab>' ,
697
+ ' <tab heading="Tab 2">' ,
698
+ ' <tabset>' ,
699
+ ' <tab heading="Tab 2A">' ,
700
+ ' <tabset>' ,
701
+ ' <tab heading="Tab 2AA">' ,
702
+ ' <span class="tab-2aa">{{ tab2aaText }}</span>' ,
703
+ ' </tab>' ,
704
+ ' </tabset>' ,
705
+ ' </tab>' ,
706
+ ' </tabset>' ,
707
+ ' </tab>' ,
708
+ ' </tabset>' ,
709
+ '</div>'
710
+ ] . join ( '\n' ) ) ( scope ) ;
711
+ scope . $apply ( ) ;
712
+
713
+ var outsideTabset = elm . find ( '.tabbable' ) . eq ( 0 ) ;
714
+ var nestedTabset = outsideTabset . find ( '.tabbable' ) ;
715
+
716
+ expect ( elm . find ( '.tabbable' ) . length ) . toEqual ( 4 ) ;
717
+ expect ( outsideTabset . find ( '.tab-pane' ) . eq ( 0 ) . find ( '.tab-1' ) . text ( ) . trim ( ) ) . toEqual ( scope . tab1Text ) ;
718
+ expect ( nestedTabset . find ( '.tab-pane' ) . eq ( 0 ) . text ( ) . trim ( ) ) . toEqual ( scope . tab1aText ) ;
719
+ expect ( nestedTabset . find ( 'ul.nav-tabs li' ) . eq ( 0 ) . text ( ) . trim ( ) ) . toEqual ( scope . tab1aHead ) ;
720
+ expect ( nestedTabset . eq ( 2 ) . find ( '.tab-pane' ) . eq ( 0 ) . find ( '.tab-2aa' ) . text ( ) . trim ( ) ) . toEqual ( scope . tab2aaText ) ;
721
+ } ) ) ;
722
+
723
+ it ( 'ng-repeat works with nested tabs' , inject ( function ( $compile , $rootScope ) {
724
+ var scope = $rootScope . $new ( ) ;
725
+ scope . tabs = [
726
+ {
727
+ tabs : [
728
+ {
729
+ content : 'tab1a'
730
+ } ,
731
+ {
732
+ content : 'tab2a'
733
+ }
734
+ ] ,
735
+ content : 'tab1'
736
+ }
737
+ ] ;
738
+ elm = $compile ( [
739
+ '<div>' ,
740
+ ' <tabset>' ,
741
+ ' <tab ng-repeat="tab in tabs">' ,
742
+ ' <tabset>' ,
743
+ ' <tab ng-repeat="innerTab in tab.tabs">' ,
744
+ ' <span class="inner-tab-content">{{ innerTab.content }}</span>' ,
745
+ ' </tab>' ,
746
+ ' </tabset>' ,
747
+ ' <span class="outer-tab-content">{{ tab.content }}</span>' ,
748
+ ' </tab>' ,
749
+ ' </tabset>' ,
750
+ '</div>'
751
+ ] . join ( '\n' ) ) ( scope ) ;
752
+ scope . $apply ( ) ;
753
+
754
+ expect ( elm . find ( '.inner-tab-content' ) . eq ( 0 ) . text ( ) . trim ( ) ) . toEqual ( scope . tabs [ 0 ] . tabs [ 0 ] . content ) ;
755
+ expect ( elm . find ( '.inner-tab-content' ) . eq ( 1 ) . text ( ) . trim ( ) ) . toEqual ( scope . tabs [ 0 ] . tabs [ 1 ] . content ) ;
756
+ expect ( elm . find ( '.outer-tab-content' ) . eq ( 0 ) . text ( ) . trim ( ) ) . toEqual ( scope . tabs [ 0 ] . content ) ;
757
+ } ) ) ;
758
+ } ) ;
650
759
} ) ;
0 commit comments