This repository was archived by the owner on May 29, 2019. It is now read-only.
Commit aedc056 1 parent ca1d1e5 commit aedc056 Copy full SHA for aedc056
File tree 2 files changed +34
-3
lines changed
2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,37 @@ describe('carousel', function() {
63
63
var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
64
64
expect ( indicators . length ) . toBe ( 3 ) ;
65
65
} ) ;
66
+
67
+ it ( 'should hide navigation when only one slide' , function ( ) {
68
+ scope . slides = [ { active :false , content :'one' } ] ;
69
+ scope . $apply ( ) ;
70
+ elm = $compile (
71
+ '<carousel interval="interval" no-transition="true">' +
72
+ '<slide ng-repeat="slide in slides" active="slide.active">' +
73
+ '{{slide.content}}' +
74
+ '</slide>' +
75
+ '</carousel>'
76
+ ) ( scope ) ;
77
+ var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
78
+ expect ( indicators . length ) . toBe ( 0 ) ;
79
+
80
+ var navNext = elm . find ( 'a.right' ) ;
81
+ expect ( navNext . length ) . toBe ( 0 ) ;
82
+
83
+ var navPrev = elm . find ( 'a.left' ) ;
84
+ expect ( navPrev . length ) . toBe ( 0 ) ;
85
+ } ) ;
86
+
87
+ it ( 'should show navigation when there are 3 slides' , function ( ) {
88
+ var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
89
+ expect ( indicators . length ) . not . toBe ( 0 ) ;
90
+
91
+ var navNext = elm . find ( 'a.right' ) ;
92
+ expect ( navNext . length ) . not . toBe ( 0 ) ;
93
+
94
+ var navPrev = elm . find ( 'a.left' ) ;
95
+ expect ( navPrev . length ) . not . toBe ( 0 ) ;
96
+ } ) ;
66
97
67
98
it ( 'should go to next when clicking next button' , function ( ) {
68
99
var navNext = elm . find ( 'a.right' ) ;
Original file line number Diff line number Diff line change 1
1
< div ng-mouseenter ="pause() " ng-mouseleave ="play() " class ="carousel ">
2
- < ol class ="carousel-indicators ">
2
+ < ol class ="carousel-indicators " ng-show =" slides().length > 1 " >
3
3
< li ng-repeat ="slide in slides() " ng-class ="{active: isActive(slide)} " ng-click ="select(slide) "> </ li >
4
4
</ ol >
5
5
< div class ="carousel-inner " ng-transclude > </ div >
6
- < a ng-click ="prev() " class ="carousel-control left "> ‹</ a >
7
- < a ng-click ="next() " class ="carousel-control right "> ›</ a >
6
+ < a ng-click ="prev() " class ="carousel-control left " ng-show =" slides().length > 1 " > ‹</ a >
7
+ < a ng-click ="next() " class ="carousel-control right " ng-show =" slides().length > 1 " > ›</ a >
8
8
</ div >
You can’t perform that action at this time.
0 commit comments