|
1 | 1 | describe('carousel', function() { |
2 | | - beforeEach(module('ui.bootstrap.carousel')); |
| 2 | + beforeEach(module('ui.bootstrap.carousel', function($compileProvider, $provide) { |
| 3 | + angular.forEach(['ngSwipeLeft', 'ngSwipeRight'], makeMock); |
| 4 | + function makeMock(name) { |
| 5 | + $provide.value(name + 'Directive', []); //remove existing directive if it exists |
| 6 | + $compileProvider.directive(name, function() { |
| 7 | + return function(scope, element, attr) { |
| 8 | + element.on(name, function() { |
| 9 | + scope.$apply(attr[name]); |
| 10 | + }); |
| 11 | + }; |
| 12 | + }); |
| 13 | + } |
| 14 | + })); |
3 | 15 | beforeEach(module('template/carousel/carousel.html', 'template/carousel/slide.html')); |
4 | 16 |
|
5 | 17 | var $rootScope, $compile, $controller, $timeout; |
@@ -114,6 +126,20 @@ describe('carousel', function() { |
114 | 126 | testSlideActive(0); |
115 | 127 | }); |
116 | 128 |
|
| 129 | + describe('swiping', function() { |
| 130 | + it('should go next on swipeLeft', function() { |
| 131 | + testSlideActive(0); |
| 132 | + elm.triggerHandler('ngSwipeLeft'); |
| 133 | + testSlideActive(1); |
| 134 | + }); |
| 135 | + |
| 136 | + it('should go prev on swipeRight', function() { |
| 137 | + testSlideActive(0); |
| 138 | + elm.triggerHandler('ngSwipeRight'); |
| 139 | + testSlideActive(2); |
| 140 | + }); |
| 141 | + }); |
| 142 | + |
117 | 143 | it('should select a slide when clicking on slide indicators', function () { |
118 | 144 | var indicators = elm.find('ol.carousel-indicators > li'); |
119 | 145 | indicators.eq(1).click(); |
|
0 commit comments