From 95ce03f000d663a22f91d22d490fdd7157183726 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Thu, 29 Dec 2016 10:40:32 +0100 Subject: Close #21249 : Add a Unit test for #21227 --- js/tests/unit/popover.js | 32 ++++++++++++++++++++++++++++++++ js/tests/unit/tooltip.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 5452def58..64c8c556a 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -332,4 +332,36 @@ $(function () { done() } }) + + QUnit.test('should hide popovers when their containing modal is closed', function (assert) { + assert.expect(1) + var done = assert.async() + var templateHTML = '' + + $(templateHTML).appendTo('#qunit-fixture') + $('#popover-test') + .on('shown.bs.popover', function () { + $('#modal-test').modal('hide') + }) + .on('hide.bs.popover', function () { + assert.ok(true, 'popover hide') + done() + }) + + $('#modal-test') + .on('shown.bs.modal', function () { + $('#popover-test').bootstrapPopover('show') + }) + .modal('show') + }) }) diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 7ff967fab..e1aec5551 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -839,4 +839,34 @@ $(function () { assert.ok(showingTooltip(), 'tooltip is faded in again') }) + QUnit.test('should hide tooltip when their containing modal is closed', function (assert) { + assert.expect(1) + var done = assert.async() + var templateHTML = '' + + $(templateHTML).appendTo('#qunit-fixture') + $('#tooltipTest') + .bootstrapTooltip({ trigger: 'manuel' }) + .on('shown.bs.tooltip', function () { + $('#modal-test').modal('hide') + }) + .on('hide.bs.tooltip', function () { + assert.ok(true, 'tooltip hide') + done() + }) + + $('#modal-test') + .on('shown.bs.modal', function () { + $('#tooltipTest').bootstrapTooltip('show') + }) + .modal('show') + }) }) -- cgit v1.2.3 From 026e1a1421a7e398f743e49710a0e9f003374753 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 28 Dec 2016 11:58:50 +0100 Subject: Allow to use nav with tab JS --- js/tests/unit/tab.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 62eece896..734648e9e 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -92,6 +92,22 @@ $(function () { assert.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'home') }) + QUnit.test('should activate element by tab id in nav list', function (assert) { + assert.expect(2) + var tabsHTML = '' + + $('').appendTo('#qunit-fixture') + + $(tabsHTML).find('a:last').bootstrapTab('show') + assert.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'profile') + + $(tabsHTML).find('a:first').bootstrapTab('show') + assert.strictEqual($('#qunit-fixture').find('.active').attr('id'), 'home') + }) + QUnit.test('should not fire shown when show is prevented', function (assert) { assert.expect(1) var done = assert.async() -- cgit v1.2.3 From c61a0059add8ed03be55601f674bf831d92898b1 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 2 Jan 2017 11:52:38 -0800 Subject: update seletors in js --- js/tests/unit/modal.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 7af5aeb27..84492cec2 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -379,8 +379,8 @@ $(function () { QUnit.test('should have a paddingRight when the modal is taller than the viewport', function (assert) { assert.expect(2) var done = assert.async() - $('').appendTo('#qunit-fixture') - $('.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed').css('padding-right', '10px') + $('
@Johann-S
').appendTo('#qunit-fixture') + $('.fixed-top, .fixed-bottom, .is-fixed, .sticky-top').css('padding-right', '10px') $('' var $dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') @@ -115,17 +115,17 @@ $(function () { QUnit.test('should not open dropdown if target is disabled via class', function (assert) { assert.expect(1) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().trigger('click') assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') @@ -133,17 +133,17 @@ $(function () { QUnit.test('should add class show to menu if clicked', function (assert) { assert.expect(1) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().trigger('click') assert.ok($dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') @@ -151,17 +151,17 @@ $(function () { QUnit.test('should test if element has a # before assuming it\'s a selector', function (assert) { assert.expect(1) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().trigger('click') assert.ok($dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') @@ -170,17 +170,17 @@ $(function () { QUnit.test('should remove "show" class if body is clicked', function (assert) { assert.expect(2) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') @@ -218,21 +218,20 @@ $(function () { QUnit.test('should remove "show" class if body is clicked, with multiple dropdowns', function (assert) { assert.expect(7) - var dropdownHTML = '' + + '' + + '' + + '' + '
' + '' + '' - + '' + + '' + '
' var $dropdowns = $(dropdownHTML).appendTo('#qunit-fixture').find('[data-toggle="dropdown"]') var $first = $dropdowns.first() @@ -291,17 +290,17 @@ $(function () { QUnit.test('should fire show and hide event', function (assert) { assert.expect(2) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') @@ -326,17 +325,17 @@ $(function () { QUnit.test('should fire shown and hidden event', function (assert) { assert.expect(2) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') @@ -360,17 +359,17 @@ $(function () { QUnit.test('should fire shown and hidden event with a relatedTarget', function (assert) { assert.expect(2) - var dropdownHTML = '' + + '' + + '' var $dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') @@ -394,19 +393,19 @@ $(function () { assert.expect(3) var done = assert.async() - var dropdownHTML = '