This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,37 @@ describe('carousel', function() {
6363 var indicators = elm . find ( 'ol.carousel-indicators > li' ) ;
6464 expect ( indicators . length ) . toBe ( 3 ) ;
6565 } ) ;
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+ } ) ;
6697
6798 it ( 'should go to next when clicking next button' , function ( ) {
6899 var navNext = elm . find ( 'a.right' ) ;
Original file line number Diff line number Diff line change 11< div ng-mouseenter ="pause() " ng-mouseleave ="play() " class ="carousel ">
2- < ol class ="carousel-indicators ">
2+ < ol class ="carousel-indicators " ng-show =" slides().length > 1 " >
33 < li ng-repeat ="slide in slides() " ng-class ="{active: isActive(slide)} " ng-click ="select(slide) "> </ li >
44 </ ol >
55 < 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 >
88</ div >
You can’t perform that action at this time.
0 commit comments