aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-08-17 18:29:15 +0200
committerJohann-S <[email protected]>2017-08-17 17:48:14 +0100
commit58994a16c589caef633682bc5e7a44d8793245df (patch)
tree1a981b2ac30126ca9d73b77c2f018f2ea8e500a1
parentd2bd8fb7a94906344d79669b74f3e432922d6b6f (diff)
downloadbootstrap-58994a16c589caef633682bc5e7a44d8793245df.tar.xz
bootstrap-58994a16c589caef633682bc5e7a44d8793245df.zip
Add a unit test to check if the carousel do not cycle when its parent isn't visible
-rw-r--r--js/tests/unit/carousel.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index cef461576..b110fbd65 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -879,4 +879,43 @@ $(function () {
}, 80)
}, 80)
})
+
+ QUnit.test('Should not go to the next item when the parent of the carousel is not visible', function (assert) {
+ assert.expect(2)
+ var done = assert.async()
+ var html = '<div id="parent" style="display: none;">'
+ + ' <div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">'
+ + ' <div class="carousel-inner">'
+ + ' <div id="firstItem" class="carousel-item active">'
+ + ' <img alt="">'
+ + ' </div>'
+ + ' <div class="carousel-item">'
+ + ' <img alt="">'
+ + ' </div>'
+ + ' <div class="carousel-item">'
+ + ' <img alt="">'
+ + ' </div>'
+ + ' <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>'
+ + ' <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>'
+ + ' </div>'
+ + '</div>'
+ var $html = $(html)
+ $html.appendTo('#qunit-fixture')
+ var $parent = $html.find('#parent')
+ var $carousel = $html.find('#myCarousel')
+ $carousel.bootstrapCarousel()
+ var $firstItem = $('#firstItem')
+
+ setTimeout(function () {
+ assert.ok($firstItem.hasClass('active'))
+ $carousel.bootstrapCarousel('dispose')
+ $parent.attr('style', 'visibility: hidden;')
+ $carousel.bootstrapCarousel()
+
+ setTimeout(function () {
+ assert.ok($firstItem.hasClass('active'))
+ done()
+ }, 80)
+ }, 80)
+ })
})