From f66a747615c5216b8cd81c699149f993e8f28608 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 21 Apr 2014 13:14:53 -0700 Subject: [PATCH] add unit tests for Carousel slid events --- js/tests/unit/carousel.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 065354451f..a4008bb0c7 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -66,6 +66,18 @@ $(function () { }).carousel('next') }) + test('should fire slid event with direction', function () { + var template = '' + $.support.transition = false + stop() + $(template).on('slid.bs.carousel', function (e) { + e.preventDefault() + ok(e.direction) + ok(e.direction === 'right' || e.direction === 'left') + start() + }).carousel('next') + }) + test('should fire slide event with relatedTarget', function () { var template = '' $.support.transition = false @@ -80,6 +92,20 @@ $(function () { .carousel('next') }) + test('should fire slid event with relatedTarget', function () { + var template = '' + $.support.transition = false + stop() + $(template) + .on('slid.bs.carousel', function (e) { + e.preventDefault() + ok(e.relatedTarget) + ok($(e.relatedTarget).hasClass('item')) + start() + }) + .carousel('next') + }) + test('should set interval from data attribute', 4, function () { var template = $('') template.attr('data-interval', 1814)