From 904efc043d298904d8020df7325bf01a5825a780 Mon Sep 17 00:00:00 2001 From: Johann Date: Tue, 28 Mar 2017 15:55:03 +0200 Subject: Fix different tooltips offset when hovering --- js/tests/unit/tooltip.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index e1aec5551..e739f06a5 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -869,4 +869,21 @@ $(function () { }) .modal('show') }) + + QUnit.test('should reset tip classes when hidden event triggered', function (assert) { + assert.expect(2) + var done = assert.async() + var $el = $('') + .appendTo('#qunit-fixture') + .bootstrapTooltip('show') + .on('hidden.bs.tooltip', function () { + var tooltip = $el.data('bs.tooltip') + var $tooltip = $(tooltip.getTipElement()) + assert.ok($tooltip.hasClass('tooltip')) + assert.ok($tooltip.hasClass('fade')) + done() + }) + + $el.bootstrapTooltip('hide') + }) }) -- cgit v1.2.3 From 5142de7e592abc0a791ea3465616795c91219bcc Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 31 Mar 2017 10:03:54 +0200 Subject: Popover + Tooltip - fix error when content or title is a number --- js/tests/unit/tooltip.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index e739f06a5..8cb1a6fdf 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -886,4 +886,20 @@ $(function () { $el.bootstrapTooltip('hide') }) + + QUnit.test('should convert number in title to string', function (assert) { + assert.expect(1) + var done = assert.async() + var $el = $('') + .appendTo('#qunit-fixture') + .bootstrapTooltip('show') + .on('shown.bs.tooltip', function () { + var tooltip = $el.data('bs.tooltip') + var $tooltip = $(tooltip.getTipElement()) + assert.strictEqual($tooltip.children().text(), '7') + done() + }) + + $el.bootstrapTooltip('show') + }) }) -- cgit v1.2.3 From b40b1bc396adb80944b887f72d0ae616277c852d Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 7 Apr 2017 13:20:34 +0200 Subject: Add attachment classes --- js/tests/unit/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 8cb1a6fdf..dc6364415 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -111,7 +111,7 @@ $(function () { assert .ok($('.tooltip') - .is('.fade.bs-tether-element-attached-top.bs-tether-element-attached-center.show'), 'has correct classes applied') + .is('.fade.bs-tooltip-bottom.show'), 'has correct classes applied') $tooltip.bootstrapTooltip('hide') -- cgit v1.2.3 From d8996a7e0a90ad2a00151c5e14bae6a37bf8e186 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Sat, 8 Apr 2017 21:13:15 +0200 Subject: Fix arrow for tooltip and popover --- js/tests/unit/tooltip.js | 83 ++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index dc6364415..0bb90156b 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -364,32 +364,31 @@ $(function () { }) QUnit.test('should add position class before positioning so that position-specific styles are taken into account', function (assert) { - assert.expect(1) + assert.expect(2) + var done = assert.async() var styles = '' var $styles = $(styles).appendTo('head') var $container = $('
').appendTo('#qunit-fixture') - var $target = $('') + $('') .appendTo($container) .bootstrapTooltip({ - placement: 'right' + placement: 'right', + trigger: 'manual' + }) + .on('inserted.bs.tooltip', function () { + var $tooltip = $($(this).data('bs.tooltip').tip) + assert.ok($tooltip.hasClass('bs-tooltip-right')) + assert.ok($tooltip.attr('style') === undefined) + $(this).bootstrapTooltip('hide') + $container.remove() + $styles.remove() + done() }) .bootstrapTooltip('show') - - var $tooltip = $($target.data('bs.tooltip').tip) - - // this is some dumb hack stuff because sub pixels in firefox - var top = Math.round($target.offset().top + $target[0].offsetHeight / 2 - $tooltip[0].offsetHeight / 2) - var top2 = Math.round($tooltip.offset().top) - var topDiff = top - top2 - assert.ok(topDiff <= 1 && topDiff >= -1) - $target.bootstrapTooltip('hide') - - $container.remove() - $styles.remove() }) QUnit.test('should use title attribute for tooltip text', function (assert) { @@ -476,6 +475,12 @@ $(function () { }) .appendTo('#qunit-fixture') + $('#qunit-fixture').css({ + position : 'relative', + top : '0px', + left : '0px' + }) + var $trigger = $container .find('a') .css('margin-top', 200) @@ -489,6 +494,11 @@ $(function () { setTimeout(function () { assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top)) + $('#qunit-fixture').css({ + position : 'absolute', + top : '-10000px', + left : '-10000px' + }) done() }, 0) }) @@ -629,45 +639,6 @@ $(function () { $tooltip.trigger('mouseenter') }) - QUnit.test('should correctly position tooltips on SVG elements', function (assert) { - if (!window.SVGElement) { - // Skip IE8 since it doesn't support SVG - assert.expect(0) - return - } - assert.expect(2) - - var done = assert.async() - - var styles = '' - var $styles = $(styles).appendTo('head') - - $('#qunit-fixture').append( - '
' - + ' ' - + ' ' - + ' ' - + '
') - var $circle = $('#theCircle') - - $circle - .on('shown.bs.tooltip', function () { - var offset = $('.tooltip').offset() - $styles.remove() - assert.ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location') - $circle.bootstrapTooltip('hide') - assert.strictEqual($('.tooltip').length, 0, 'tooltip removed from dom') - done() - }) - .bootstrapTooltip({ placement: 'top', trigger: 'manual' }) - - $circle.bootstrapTooltip('show') - }) - QUnit.test('should not reload the tooltip on subsequent mouseenter events', function (assert) { assert.expect(1) var titleHtml = function () { -- cgit v1.2.3 From 69de65180f750cadf5f96a774d2524f69d19beab Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 14 Apr 2017 13:30:55 +0200 Subject: Fix unit tests + Update Popper to 1.6.0 --- js/tests/unit/tooltip.js | 64 +++++------------------------------------------- 1 file changed, 6 insertions(+), 58 deletions(-) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 0bb90156b..f47a97e30 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -383,8 +383,6 @@ $(function () { var $tooltip = $($(this).data('bs.tooltip').tip) assert.ok($tooltip.hasClass('bs-tooltip-right')) assert.ok($tooltip.attr('style') === undefined) - $(this).bootstrapTooltip('hide') - $container.remove() $styles.remove() done() }) @@ -475,32 +473,19 @@ $(function () { }) .appendTo('#qunit-fixture') - $('#qunit-fixture').css({ - position : 'relative', - top : '0px', - left : '0px' - }) - - var $trigger = $container + $container .find('a') .css('margin-top', 200) .bootstrapTooltip({ placement: 'top', animate: false }) - .bootstrapTooltip('show') - - var $tooltip = $($trigger.data('bs.tooltip').tip) - - setTimeout(function () { - assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top)) - $('#qunit-fixture').css({ - position : 'absolute', - top : '-10000px', - left : '-10000px' + .on('shown.bs.tooltip', function () { + var $tooltip = $($(this).data('bs.tooltip').tip) + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + done() }) - done() - }, 0) + .bootstrapTooltip('show') }) QUnit.test('should show tooltip if leave event hasn\'t occurred before delay expires', function (assert) { @@ -702,43 +687,6 @@ $(function () { assert.strictEqual(currentUid, $('#tt-content').text()) }) - QUnit.test('should correctly position tooltips on transformed elements', function (assert) { - var styleProps = document.documentElement.style - if (!('transform' in styleProps) && !('webkitTransform' in styleProps) && !('msTransform' in styleProps)) { - assert.expect(0) - return - } - assert.expect(2) - - var done = assert.async() - - var styles = '' - var $styles = $(styles).appendTo('head') - - var $element = $('
').appendTo('#qunit-fixture') - - $element - .on('shown.bs.tooltip', function () { - var offset = $('.tooltip').offset() - $styles.remove() - assert.ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location') - assert.ok(Math.abs(offset.top - 126) <= 1, 'tooltip has correct vertical location') - $element.bootstrapTooltip('hide') - done() - }) - .bootstrapTooltip({ - trigger: 'manual' - }) - - $element.bootstrapTooltip('show') - }) - QUnit.test('should do nothing when an attempt is made to hide an uninitialized tooltip', function (assert) { assert.expect(1) -- cgit v1.2.3 From 53ee455bc735af9fc54de586ed4d23ac56b69ab8 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 17 Apr 2017 14:26:40 +0200 Subject: Handle dropup for Dropdown --- js/tests/unit/tooltip.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index f47a97e30..c0cafefe5 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -456,7 +456,7 @@ $(function () { assert.expect(1) var done = assert.async() - var containerHTML = '
' + var containerHTML = '
' + '

' + 'Hover me' + '

' @@ -482,7 +482,12 @@ $(function () { }) .on('shown.bs.tooltip', function () { var $tooltip = $($(this).data('bs.tooltip').tip) - assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + if (/iPhone|iPad|iPod/.test(navigator.userAgent)) { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($(this).offset().top)) + } + else { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + } done() }) .bootstrapTooltip('show') -- cgit v1.2.3