aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2018-10-29 14:27:19 +0100
committerJohann-S <[email protected]>2018-10-29 14:49:29 +0100
commit91f8077ed5cfff2ee61e50a39a25982ef8c4b01f (patch)
tree07940c92446a0213a50ac186536e2bc6e54007d4 /js/tests
parentbb0d6bf178de310176d914f73f2f649c229d8c4e (diff)
downloadbootstrap-91f8077ed5cfff2ee61e50a39a25982ef8c4b01f.tar.xz
bootstrap-91f8077ed5cfff2ee61e50a39a25982ef8c4b01f.zip
add unit tests for our carousel
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/carousel.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index d7d9ad250..d6fea2f34 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -1226,4 +1226,48 @@ $(function () {
done()
})
})
+
+ QUnit.test('should not call _slide if the carousel is sliding', function (assert) {
+ assert.expect(1)
+
+ var carouselHTML = '<div class="carousel" data-interval="false"></div>'
+ var $carousel = $(carouselHTML)
+ $carousel.appendTo('#qunit-fixture')
+ $carousel.bootstrapCarousel()
+
+ var carousel = $carousel.data('bs.carousel')
+
+ var spy = sinon.spy(carousel, '_slide')
+
+ carousel._isSliding = true
+
+ carousel.next()
+
+ assert.strictEqual(spy.called, false)
+ })
+
+ QUnit.test('should call next when the page is visible', function (assert) {
+ assert.expect(1)
+
+ var carouselHTML = '<div class="carousel" data-interval="false"></div>'
+ var $carousel = $(carouselHTML)
+ $carousel.appendTo('#qunit-fixture')
+ $carousel.bootstrapCarousel()
+
+ var carousel = $carousel.data('bs.carousel')
+
+ var spy = sinon.spy(carousel, 'next')
+ var sandbox = sinon.createSandbox()
+
+ sandbox.replaceGetter(document, 'hidden', function () {
+ return false
+ })
+ sandbox.stub($carousel, 'is').returns(true)
+ sandbox.stub($carousel, 'css').returns('block')
+
+ carousel.nextWhenVisible()
+
+ assert.strictEqual(spy.called, true)
+ sandbox.restore()
+ })
})