aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2016-05-30 09:39:45 -0700
committerChris Rebert <[email protected]>2016-05-30 09:39:45 -0700
commit14c7ba95f97d853ef653893abfe530a919a1ed24 (patch)
treed7695b3253a2101e819aef057fa9f15df01299b8
parentd35973c2b3eacd15b297863ba79bcc46d877ba52 (diff)
downloadbootstrap-14c7ba95f97d853ef653893abfe530a919a1ed24.tar.xz
bootstrap-14c7ba95f97d853ef653893abfe530a919a1ed24.zip
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]
-rw-r--r--js/tests/unit/scrollspy.js14
1 files changed, 7 insertions, 7 deletions
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')