From aedc05654b19342d96eabc4fc08d6a090765a48b Mon Sep 17 00:00:00 2001 From: Matt Raible Date: Tue, 12 Mar 2013 11:59:21 -0600 Subject: [PATCH] feat(carousel): Hide navigation indicators if only one slide --- src/carousel/test/carousel.spec.js | 31 ++++++++++++++++++++++++++++++ template/carousel/carousel.html | 6 +++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index 6749c84b9b..a962bc15dc 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -63,6 +63,37 @@ describe('carousel', function() { var indicators = elm.find('ol.carousel-indicators > li'); expect(indicators.length).toBe(3); }); + + it('should hide navigation when only one slide', function () { + scope.slides=[{active:false,content:'one'}]; + scope.$apply(); + elm = $compile( + '' + + '' + + '{{slide.content}}' + + '' + + '' + )(scope); + var indicators = elm.find('ol.carousel-indicators > li'); + expect(indicators.length).toBe(0); + + var navNext = elm.find('a.right'); + expect(navNext.length).toBe(0); + + var navPrev = elm.find('a.left'); + expect(navPrev.length).toBe(0); + }); + + it('should show navigation when there are 3 slides', function () { + var indicators = elm.find('ol.carousel-indicators > li'); + expect(indicators.length).not.toBe(0); + + var navNext = elm.find('a.right'); + expect(navNext.length).not.toBe(0); + + var navPrev = elm.find('a.left'); + expect(navPrev.length).not.toBe(0); + }); it('should go to next when clicking next button', function() { var navNext = elm.find('a.right'); diff --git a/template/carousel/carousel.html b/template/carousel/carousel.html index aede73959e..97fad9f3f1 100644 --- a/template/carousel/carousel.html +++ b/template/carousel/carousel.html @@ -1,8 +1,8 @@