Mercurial > wikked
comparison static/bootstrap/js/tests/unit/bootstrap-collapse.js @ 88:a5a3d454eac9
Updated Bootstrap.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 05 Apr 2013 08:08:12 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
87:c0cf67362fb1 | 88:a5a3d454eac9 |
---|---|
1 $(function () { | |
2 | |
3 module("bootstrap-collapse") | |
4 | |
5 test("should provide no conflict", function () { | |
6 var collapse = $.fn.collapse.noConflict() | |
7 ok(!$.fn.collapse, 'collapse was set back to undefined (org value)') | |
8 $.fn.collapse = collapse | |
9 }) | |
10 | |
11 test("should be defined on jquery object", function () { | |
12 ok($(document.body).collapse, 'collapse method is defined') | |
13 }) | |
14 | |
15 test("should return element", function () { | |
16 ok($(document.body).collapse()[0] == document.body, 'document.body returned') | |
17 }) | |
18 | |
19 test("should show a collapsed element", function () { | |
20 var el = $('<div class="collapse"></div>').collapse('show') | |
21 ok(el.hasClass('in'), 'has class in') | |
22 ok(/height/.test(el.attr('style')), 'has height set') | |
23 }) | |
24 | |
25 test("should hide a collapsed element", function () { | |
26 var el = $('<div class="collapse"></div>').collapse('hide') | |
27 ok(!el.hasClass('in'), 'does not have class in') | |
28 ok(/height/.test(el.attr('style')), 'has height set') | |
29 }) | |
30 | |
31 test("should not fire shown when show is prevented", function () { | |
32 $.support.transition = false | |
33 stop() | |
34 $('<div class="collapse"/>') | |
35 .bind('show', function (e) { | |
36 e.preventDefault(); | |
37 ok(true); | |
38 start(); | |
39 }) | |
40 .bind('shown', function () { | |
41 ok(false); | |
42 }) | |
43 .collapse('show') | |
44 }) | |
45 | |
46 test("should reset style to auto after finishing opening collapse", function () { | |
47 $.support.transition = false | |
48 stop() | |
49 $('<div class="collapse" style="height: 0px"/>') | |
50 .bind('show', function () { | |
51 ok(this.style.height == '0px') | |
52 }) | |
53 .bind('shown', function () { | |
54 ok(this.style.height == 'auto') | |
55 start() | |
56 }) | |
57 .collapse('show') | |
58 }) | |
59 | |
60 test("should add active class to target when collapse shown", function () { | |
61 $.support.transition = false | |
62 stop() | |
63 | |
64 var target = $('<a data-toggle="collapse" href="#test1"></a>') | |
65 .appendTo($('#qunit-fixture')) | |
66 | |
67 var collapsible = $('<div id="test1"></div>') | |
68 .appendTo($('#qunit-fixture')) | |
69 .on('show', function () { | |
70 ok(!target.hasClass('collapsed')) | |
71 start() | |
72 }) | |
73 | |
74 target.click() | |
75 }) | |
76 | |
77 test("should remove active class to target when collapse hidden", function () { | |
78 $.support.transition = false | |
79 stop() | |
80 | |
81 var target = $('<a data-toggle="collapse" href="#test1"></a>') | |
82 .appendTo($('#qunit-fixture')) | |
83 | |
84 var collapsible = $('<div id="test1" class="in"></div>') | |
85 .appendTo($('#qunit-fixture')) | |
86 .on('hide', function () { | |
87 ok(target.hasClass('collapsed')) | |
88 start() | |
89 }) | |
90 | |
91 target.click() | |
92 }) | |
93 | |
94 }) |