aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2015-05-04 15:07:17 -0700
committerChris Rebert <[email protected]>2015-05-04 15:07:17 -0700
commitaa2c5b5672f5a7b8b0419bee51023f7e9ae4acba (patch)
tree7c3fefdac766ac902f796450cc51da42b13f9829 /js/tests
parenta19441dd643c17baf7672987430c4607cfa229e9 (diff)
parent4b269037cb42cce7898d57890db40ef0cc3bd5f8 (diff)
downloadbootstrap-aa2c5b5672f5a7b8b0419bee51023f7e9ae4acba.tar.xz
bootstrap-aa2c5b5672f5a7b8b0419bee51023f7e9ae4acba.zip
Merge pull request #16014 from redbmk/issue-16008
Multiple tooltip triggers don't play well together
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/tooltip.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index bdcf0bbd0..27ce6208e 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -1284,4 +1284,42 @@ $(function () {
}, new Error('tooltip `template` option must consist of exactly 1 top-level element!'))
})
+ QUnit.test('should not remove tooltip if multiple triggers are set and one is still active', function (assert) {
+ assert.expect(41)
+ var $el = $('<button>Trigger</button>')
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip({ trigger: 'click hover focus', animation: false })
+ var tooltip = $el.data('bs.tooltip')
+ var $tooltip = tooltip.tip()
+
+ function showingTooltip() { return $tooltip.hasClass('in') || tooltip.hoverState == 'in' }
+
+ var tests = [
+ ['mouseenter', 'mouseleave'],
+
+ ['focusin', 'focusout'],
+
+ ['click', 'click'],
+
+ ['mouseenter', 'focusin', 'focusout', 'mouseleave'],
+ ['mouseenter', 'focusin', 'mouseleave', 'focusout'],
+
+ ['focusin', 'mouseenter', 'mouseleave', 'focusout'],
+ ['focusin', 'mouseenter', 'focusout', 'mouseleave'],
+
+ ['click', 'focusin', 'mouseenter', 'focusout', 'mouseleave', 'click'],
+ ['mouseenter', 'click', 'focusin', 'focusout', 'mouseleave', 'click'],
+ ['mouseenter', 'focusin', 'click', 'click', 'mouseleave', 'focusout']
+ ]
+
+ assert.ok(!showingTooltip())
+
+ $.each(tests, function (idx, triggers) {
+ for (var i = 0, len = triggers.length; i < len; i++) {
+ $el.trigger(triggers[i]);
+ assert.equal(i < (len - 1), showingTooltip())
+ }
+ })
+ })
+
})