aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorBraden M. Kelley <[email protected]>2015-03-06 17:52:59 -0800
committerBraden M. Kelley <[email protected]>2015-04-27 23:03:56 -0700
commit4b269037cb42cce7898d57890db40ef0cc3bd5f8 (patch)
treeee9c9b430bd160b85202877d3fdf16270961dcf3 /js/tests
parent421eacb1b1f53ea3e55b7961a87fd2d468a6da08 (diff)
downloadbootstrap-4b269037cb42cce7898d57890db40ef0cc3bd5f8.tar.xz
bootstrap-4b269037cb42cce7898d57890db40ef0cc3bd5f8.zip
Multiple tooltip triggers don't play well together
Fixes issue #16008
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())
+ }
+ })
+ })
+
})