aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-09-25 12:41:54 +0200
committerJohann-S <[email protected]>2017-09-25 13:23:13 +0200
commit9b8356ba52d89fd065d6061979b5946b8c5f44fa (patch)
tree3c78f94c599eb0ba9d052742abb8e8fe5d926fba /js/tests
parent3abf8a0e5525d30914ce37ebb98240a476cb6f17 (diff)
downloadbootstrap-9b8356ba52d89fd065d6061979b5946b8c5f44fa.tar.xz
bootstrap-9b8356ba52d89fd065d6061979b5946b8c5f44fa.zip
Collapse - Allow to pass jQuery object or DOM element to the parent option
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/collapse.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js
index 9ecb60994..c36fe25be 100644
--- a/js/tests/unit/collapse.js
+++ b/js/tests/unit/collapse.js
@@ -698,4 +698,48 @@ $(function () {
$target.trigger($.Event('click'))
})
+
+ QUnit.test('should allow jquery object in parent config', function (assert) {
+ assert.expect(1)
+ var html =
+ '<div class="my-collapse">' +
+ ' <div class="item">' +
+ ' <a data-toggle="collapse" href="#">Toggle item</a>' +
+ ' <div class="collapse">Lorem ipsum</div>' +
+ ' </div>' +
+ '</div>'
+
+ $(html).appendTo('#qunit-fixture')
+ try {
+ $('[data-toggle="collapse"]').bootstrapCollapse({
+ parent: $('.my-collapse')
+ })
+ assert.ok(true, 'collapse correctly created')
+ }
+ catch (e) {
+ assert.ok(false, 'collapse not created')
+ }
+ })
+
+ QUnit.test('should allow DOM object in parent config', function (assert) {
+ assert.expect(1)
+ var html =
+ '<div class="my-collapse">' +
+ ' <div class="item">' +
+ ' <a data-toggle="collapse" href="#">Toggle item</a>' +
+ ' <div class="collapse">Lorem ipsum</div>' +
+ ' </div>' +
+ '</div>'
+
+ $(html).appendTo('#qunit-fixture')
+ try {
+ $('[data-toggle="collapse"]').bootstrapCollapse({
+ parent: $('.my-collapse')[0]
+ })
+ assert.ok(true, 'collapse correctly created')
+ }
+ catch (e) {
+ assert.ok(false, 'collapse not created')
+ }
+ })
})