aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorfat <[email protected]>2015-05-13 13:43:56 -0700
committerfat <[email protected]>2015-05-13 13:43:56 -0700
commitb0d142334f0d15e63577b28e2d7045c2199dcd6a (patch)
tree6fe7abb420ee0ea4bc4cc100a8410f300967b570 /js/tests
parent7ef0e52fd042da2fdf107a3347abab3486a67790 (diff)
downloadbootstrap-b0d142334f0d15e63577b28e2d7045c2199dcd6a.tar.xz
bootstrap-b0d142334f0d15e63577b28e2d7045c2199dcd6a.zip
fix #15301
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/scrollspy.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index bf963b3ab..a4407ece9 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -77,6 +77,51 @@ $(function () {
$scrollspy.scrollTop(350)
})
+ QUnit.test('should only switch "active" class on current target specified w element', function (assert) {
+ assert.expect(1)
+ var done = assert.async()
+
+ var sectionHTML = '<div id="root" class="active">'
+ + '<div class="topbar">'
+ + '<div class="topbar-inner">'
+ + '<div class="container" id="ss-target">'
+ + '<ul class="nav">'
+ + '<li><a href="#masthead">Overview</a></li>'
+ + '<li><a href="#detail">Detail</a></li>'
+ + '</ul>'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ + '<div id="scrollspy-example" style="height: 100px; overflow: auto;">'
+ + '<div style="height: 200px;">'
+ + '<h4 id="masthead">Overview</h4>'
+ + '<p style="height: 200px">'
+ + 'Ad leggings keytar, brunch id art party dolor labore.'
+ + '</p>'
+ + '</div>'
+ + '<div style="height: 200px;">'
+ + '<h4 id="detail">Detail</h4>'
+ + '<p style="height: 200px">'
+ + 'Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard.'
+ + '</p>'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ var $section = $(sectionHTML).appendTo('#qunit-fixture')
+
+ var $scrollspy = $section
+ .show()
+ .find('#scrollspy-example')
+ .bootstrapScrollspy({ target: $('#ss-target') })
+
+ $scrollspy.on('scroll.bs.scrollspy', function () {
+ assert.ok($section.hasClass('active'), '"active" class still on root node')
+ done()
+ })
+
+ $scrollspy.scrollTop(350)
+ })
+
QUnit.test('should correctly select middle navigation option when large offset is used', function (assert) {
assert.expect(3)
var done = assert.async()