aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/collapse.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/collapse.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/collapse.js')
-rw-r--r--js/tests/unit/collapse.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js
index 66b2dc1a7..a8c6e38a5 100644
--- a/js/tests/unit/collapse.js
+++ b/js/tests/unit/collapse.js
@@ -1,29 +1,38 @@
$(function () {
- module('collapse')
-
- test('should provide no conflict', function () {
- var collapse = $.fn.collapse.noConflict()
- ok(!$.fn.collapse, 'collapse was set back to undefined (org value)')
- $.fn.collapse = collapse
- })
+ module('collapse plugin')
test('should be defined on jquery object', function () {
ok($(document.body).collapse, 'collapse method is defined')
})
+ module('collapse', {
+ setup: function() {
+ // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
+ $.fn.bootstrapCollapse = $.fn.collapse.noConflict()
+ },
+ teardown: function() {
+ $.fn.collapse = $.fn.bootstrapCollapse
+ delete $.fn.bootstrapCollapse
+ }
+ })
+
+ test('should provide no conflict', function () {
+ ok(!$.fn.collapse, 'collapse was set back to undefined (org value)')
+ })
+
test('should return element', function () {
- ok($(document.body).collapse()[0] == document.body, 'document.body returned')
+ ok($(document.body).bootstrapCollapse()[0] == document.body, 'document.body returned')
})
test('should show a collapsed element', function () {
- var el = $('<div class="collapse"></div>').collapse('show')
+ var el = $('<div class="collapse"></div>').bootstrapCollapse('show')
ok(el.hasClass('in'), 'has class in')
ok(!/height/.test(el.attr('style')), 'has height reset')
})
test('should hide a collapsed element', function () {
- var el = $('<div class="collapse"></div>').collapse('hide')
+ var el = $('<div class="collapse"></div>').bootstrapCollapse('hide')
ok(!el.hasClass('in'), 'does not have class in')
ok(/height/.test(el.attr('style')), 'has height set')
})
@@ -40,7 +49,7 @@ $(function () {
.on('shown.bs.collapse', function () {
ok(false)
})
- .collapse('show')
+ .bootstrapCollapse('show')
})
test('should reset style to auto after finishing opening collapse', function () {
@@ -54,7 +63,7 @@ $(function () {
ok(this.style.height === '')
start()
})
- .collapse('show')
+ .bootstrapCollapse('show')
})
test('should add active class to target when collapse shown', function () {