aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/carousel.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-11-11 19:25:16 -0800
committerMark Otto <[email protected]>2014-11-11 19:25:16 -0800
commit1e268ddfc30def5f4b2b0f2ace34b7de549ea830 (patch)
tree7cc63bc43a6c3b603cef4f004a2285e5c034a710 /js/tests/unit/carousel.js
parent4f6aeaa6347725436296131c4d2b059243390a04 (diff)
parent001d5e00c58bbb8e4d34c085c5b27b214a475bd5 (diff)
downloadbootstrap-1e268ddfc30def5f4b2b0f2ace34b7de549ea830.tar.xz
bootstrap-1e268ddfc30def5f4b2b0f2ace34b7de549ea830.zip
Merge branch 'master' into labels-readme
Diffstat (limited to 'js/tests/unit/carousel.js')
-rw-r--r--js/tests/unit/carousel.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index 6f0b9642f..5998abe6a 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -478,6 +478,48 @@ $(function () {
strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press')
})
+ test('should ignore keyboard events within <input>s and <textarea>s', function () {
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
+ + '<div class="carousel-inner">'
+ + '<div id="first" class="item active">'
+ + '<img alt="">'
+ + '<input type="text" id="in-put">'
+ + '<textarea id="text-area"></textarea>'
+ + '</div>'
+ + '<div id="second" class="item">'
+ + '<img alt="">'
+ + '</div>'
+ + '<div id="third" class="item">'
+ + '<img alt="">'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ var $template = $(templateHTML)
+ var $input = $template.find('#in-put')
+ var $textarea = $template.find('#text-area')
+
+ strictEqual($input.length, 1, 'found <input>')
+ strictEqual($textarea.length, 1, 'found <textarea>')
+
+ $template.bootstrapCarousel()
+
+ strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active')
+
+
+ $input.trigger($.Event('keydown', { which: 39 }))
+ strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>')
+
+ $input.trigger($.Event('keydown', { which: 37 }))
+ strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>')
+
+
+ $textarea.trigger($.Event('keydown', { which: 39 }))
+ strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>')
+
+ $textarea.trigger($.Event('keydown', { which: 37 }))
+ strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>')
+ })
+
test('should only add mouseenter and mouseleave listeners when not on mobile', function () {
var isMobile = 'ontouchstart' in document.documentElement
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">'