From 32f9a5d6a594aaa4afd62b2410b45804edb737c5 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 11 Sep 2015 10:45:08 +0200 Subject: fix resetting style on closing collapse --- js/tests/unit/collapse.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 78fafc6c2..e1bd8855c 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -78,6 +78,21 @@ $(function () { .bootstrapCollapse('show') }) + QUnit.test('should reset style to auto after finishing closing collapse', function (assert) { + assert.expect(1) + var done = assert.async() + + $('
') + .on('shown.bs.collapse', function () { + $(this).bootstrapCollapse('hide') + }) + .on('hidden.bs.collapse', function () { + assert.strictEqual(this.style.height, '', 'height is auto') + done() + }) + .bootstrapCollapse('show') + }) + QUnit.test('should remove "collapsed" class from target when collapse is shown', function (assert) { assert.expect(1) var done = assert.async() -- cgit v1.2.3 From d35973c2b3eacd15b297863ba79bcc46d877ba52 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sun, 29 May 2016 18:36:09 -0700 Subject: js/tests/unit/scrollspy.js: Fix "offsed" typos (#19985) [skip sauce] [skip validator] --- js/tests/unit/scrollspy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index 878c4d389..cc78f4d6d 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -362,7 +362,7 @@ $(function () { var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') - assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offsed method with ' + type + ' option') + assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offset method with ' + type + ' option') assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option') deferred.resolve() @@ -405,7 +405,7 @@ $(function () { var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') - assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offsed method with ' + type + ' option') + assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offset method with ' + type + ' option') assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option') deferred.resolve() -- cgit v1.2.3 From 14c7ba95f97d853ef653893abfe530a919a1ed24 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 30 May 2016 09:39:45 -0700 Subject: Fix load & scroll event usage in ScrollSpy tests (#19986) * Use $.one() instead of $.on() since there are no $.off()s in the code. * Remove unnecessary namespacing of listeners for the `scroll` & `load` events. These are vanilla DOM events (not custom jQuery namespaced events) and we're not using jQuery namespacing to manage these event listeners either (e.g. `$.off()`). [skip validator] --- js/tests/unit/scrollspy.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index cc78f4d6d..ccb3e6d9c 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -81,7 +81,7 @@ $(function () { .find('#scrollspy-example') .bootstrapScrollspy({ target: '#ss-target' }) - $scrollspy.on('scroll.bs.scrollspy', function () { + $scrollspy.one('scroll', function () { assert.ok($section.hasClass('active'), '"active" class still on root node') done() }) @@ -126,7 +126,7 @@ $(function () { .find('#scrollspy-example') .bootstrapScrollspy({ target: document.getElementById('#ss-target') }) - $scrollspy.on('scroll.bs.scrollspy', function () { + $scrollspy.one('scroll', function () { assert.ok($section.hasClass('active'), '"active" class still on root node') done() }) @@ -158,7 +158,7 @@ $(function () { $scrollspy.bootstrapScrollspy({ target: '#navigation', offset: $scrollspy.position().top }) - $scrollspy.on('scroll.bs.scrollspy', function () { + $scrollspy.one('scroll', function () { assert.ok(!$section.find('#one-link').hasClass('active'), '"active" class removed from first section') assert.ok($section.find('#two-link').hasClass('active'), '"active" class on middle section') assert.ok(!$section.find('#three-link').hasClass('active'), '"active" class not on last section') @@ -272,11 +272,11 @@ $(function () { target: '#navigation', offset: $scrollspy.position().top }) - .one('scroll.bs.scrollspy', function () { + .one('scroll', function () { assert.strictEqual($('.active').length, 1, '"active" class on only one element present') assert.strictEqual($('.active').is('#two-link'), true, '"active" class on second section') $scrollspy - .one('scroll.bs.scrollspy', function () { + .one('scroll', function () { assert.strictEqual($('.active').length, 0, 'selection cleared') done() }) @@ -357,7 +357,7 @@ $(function () { .appendTo('#qunit-fixture') if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'offset' }) - else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api') + else if (type === 'data') $(window).trigger('load') var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') @@ -400,7 +400,7 @@ $(function () { .appendTo('#qunit-fixture') if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) - else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api') + else if (type === 'data') $(window).trigger('load') var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') -- cgit v1.2.3 From aa369bd8f98bd34d97f1a4674f2a81dcebc9724c Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sun, 26 Jun 2016 21:33:07 -0700 Subject: Remove unnecessary usage of Promises in non-async ScrollSpy tests (#20180) Closes #19906 [skip validator] --- js/tests/unit/scrollspy.js | 54 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index ccb3e6d9c..b04a9d863 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -335,8 +335,7 @@ $(function () { assert.expect(4) var testOffsetMethod = function (type) { - var deferred = $.Deferred() - var navbarHtml = + var $navbar = $( '' - var contentHtml = + ) + var $content = $( '
' + '
div 1
' + '
div 2
' + '
div 3
' + '
' + ) + $navbar.appendTo('#qunit-fixture') + $content.appendTo('#qunit-fixture') - $(navbarHtml).appendTo('#qunit-fixture') - var $content = $(contentHtml) - .appendTo('#qunit-fixture') - - if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'offset' }) - else if (type === 'data') $(window).trigger('load') + if (type === 'js') { + $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'offset' }) + } + else if (type === 'data') { + $(window).trigger('load') + } var $target = $('#div-' + type + 'm-2') var scrollspy = $content.data('bs.scrollspy') assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offset method with ' + type + ' option') assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option') - - deferred.resolve() - - return deferred.promise() + $navbar.remove() + $content.remove() } - $.when(testOffsetMethod('js')) - .then(function () { testOffsetMethod('data') }) + testOffsetMethod('js') + testOffsetMethod('data') }) QUnit.test('should allow passed in option offset method: position', function (assert) { assert.expect(4) var testOffsetMethod = function (type) { - var deferred = $.Deferred() - var navbarHtml = + var $navbar = $( '' - var contentHtml = + ) + var $content = $( '
' + '
div 1
' + '
div 2
' + '
div 3
' + '
' + ) - - $(navbarHtml).appendTo('#qunit-fixture') - var $content = $(contentHtml) - .appendTo('#qunit-fixture') + $navbar.appendTo('#qunit-fixture') + $content.appendTo('#qunit-fixture') if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) else if (type === 'data') $(window).trigger('load') @@ -407,14 +407,12 @@ $(function () { assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offset method with ' + type + ' option') assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option') - - deferred.resolve() - - return deferred.promise() + $navbar.remove() + $content.remove() } - $.when(testOffsetMethod('js')) - .then(function () { testOffsetMethod('data') }) + testOffsetMethod('js') + testOffsetMethod('data') }) }) -- cgit v1.2.3 From 208d587c7ec0ea93c0d03c15d98952c8470af189 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Mon, 27 Jun 2016 21:41:00 -0400 Subject: Scrollspy test: Allow for async .then() in jQuery 3; fixes #20182 Instead of doing a new assert.async(), just do a single one for the entire test and let the .then() be async as well. Closes #20190 --- js/tests/unit/scrollspy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index b04a9d863..772fedc2e 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -314,21 +314,21 @@ $(function () { var testElementIsActiveAfterScroll = function (element, target) { var deferred = $.Deferred() var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top) - var done = assert.async() $content.one('scroll', function () { assert.ok($(element).hasClass('active'), 'target:' + target + ', element: ' + element) - done() deferred.resolve() }) $content.scrollTop(scrollHeight) return deferred.promise() } + var done = assert.async() $.when(testElementIsActiveAfterScroll('#li-100-5', '#div-100-5')) .then(function () { return testElementIsActiveAfterScroll('#li-100-4', '#div-100-4') }) .then(function () { return testElementIsActiveAfterScroll('#li-100-3', '#div-100-3') }) .then(function () { return testElementIsActiveAfterScroll('#li-100-2', '#div-100-2') }) .then(function () { return testElementIsActiveAfterScroll('#li-100-1', '#div-100-1') }) + .then(function () { done() }) }) QUnit.test('should allow passed in option offset method: offset', function (assert) { -- cgit v1.2.3 From 8900d953ed8b7d2416c2c31667790d83853a0a06 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 28 Jun 2016 13:24:28 -0700 Subject: ScrollSpy unit test: Use single done() in a then() instead of multiple done()s (#20198) Fixes test flakiness on OS X Safari and Android when using jQuery 3. Fixes #20182 more Refs #20191 --- js/tests/unit/scrollspy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js index 772fedc2e..97ddd16ec 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -188,13 +188,12 @@ $(function () { .appendTo('#qunit-fixture') .bootstrapScrollspy({ offset: 0, target: '.navbar' }) + var done = assert.async() var testElementIsActiveAfterScroll = function (element, target) { var deferred = $.Deferred() var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top) - var done = assert.async() $content.one('scroll', function () { assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element) - done() deferred.resolve() }) $content.scrollTop(scrollHeight) @@ -203,6 +202,7 @@ $(function () { $.when(testElementIsActiveAfterScroll('#a-1', '#div-1')) .then(function () { return testElementIsActiveAfterScroll('#a-2', '#div-2') }) + .then(function () { done() }) }) QUnit.test('should add the active class correctly when there are nested elements at 0 scroll offset', function (assert) { -- cgit v1.2.3 From 63129112bbea91f7cd62014f162f857f50084656 Mon Sep 17 00:00:00 2001 From: VarelloThemes Date: Thu, 15 Sep 2016 17:39:31 +0100 Subject: replace some profanities (#20715) --- js/tests/unit/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 9ec5ddb03..6cf870551 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -368,7 +368,7 @@ $(function () { var $tooltip = $($target.data('bs.tooltip').tip) - // this is some dumb hack shit because sub pixels in firefox + // 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 -- cgit v1.2.3 From de1255b14e9d1bbfc1a3b055477f4fc15cc974af Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 1 Dec 2015 23:17:35 +0100 Subject: Collapse using card component --- js/tests/unit/collapse.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index d387ebb18..892da52ed 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -235,12 +235,12 @@ $(function () { assert.expect(3) var done = assert.async() - var accordionHTML = '