aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/scrollspy.js
diff options
context:
space:
mode:
authorCollin Donahue-Oponski <[email protected]>2014-04-21 23:03:33 -0600
committerCollin Donahue-Oponski <[email protected]>2014-04-21 23:03:33 -0600
commita9f2b6ce0fb2ac059e30da259f7ae25282803c09 (patch)
tree33aa8358b29db57532dbf2d8560649c7e11f2628 /js/tests/unit/scrollspy.js
parent9c4afc577253ada54d3ff27965e380a5c9f4e60e (diff)
downloadbootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.tar.xz
bootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.zip
#11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object
Diffstat (limited to 'js/tests/unit/scrollspy.js')
-rw-r--r--js/tests/unit/scrollspy.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index 670735a46..90c95d769 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -1,19 +1,28 @@
$(function () {
- module('scrollspy')
-
- test('should provide no conflict', function () {
- var scrollspy = $.fn.scrollspy.noConflict()
- ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
- $.fn.scrollspy = scrollspy
- })
+ module('scrollspy plugin')
test('should be defined on jquery object', function () {
ok($(document.body).scrollspy, 'scrollspy method is defined')
})
+ module('scrollspy', {
+ setup: function() {
+ // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
+ $.fn.bootstrapScrollspy = $.fn.scrollspy.noConflict()
+ },
+ teardown: function() {
+ $.fn.scrollspy = $.fn.bootstrapScrollspy
+ delete $.fn.bootstrapScrollspy
+ }
+ })
+
+ test('should provide no conflict', function () {
+ ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
+ })
+
test('should return element', function () {
- ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
+ ok($(document.body).bootstrapScrollspy()[0] == document.body, 'document.body returned')
})
test('should switch active class on scroll', function () {
@@ -27,7 +36,7 @@ $(function () {
'</div>' +
'</div>' +
'</div>',
- $topbar = $(topbarHTML).scrollspy()
+ $topbar = $(topbarHTML).bootstrapScrollspy()
$(sectionHTML).append('#qunit-fixture')
ok($topbar.find('.active', true))
@@ -64,7 +73,7 @@ $(function () {
$scrollSpy = $section
.show()
.find('#scrollspy-example')
- .scrollspy({target: '#ss-target'})
+ .bootstrapScrollspy({target: '#ss-target'})
$scrollSpy.scrollTop(350);
ok($section.hasClass('active'), 'Active class still on root node')