aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKlaus Hartl <klaus.hartl@googlemail.com>2008-10-02 14:20:35 +0000
committerKlaus Hartl <klaus.hartl@googlemail.com>2008-10-02 14:20:35 +0000
commitc2b0afd3e7dce76f01fa6661993cbf08105d22cb (patch)
tree1b4b2d1f03f50f3a91e0791830e8bb3b1500f146 /tests
parentde7d22a02e72646d159f161ebfa07b6abadddbc8 (diff)
downloadjquery-ui-c2b0afd3e7dce76f01fa6661993cbf08105d22cb.tar.gz
jquery-ui-c2b0afd3e7dce76f01fa6661993cbf08105d22cb.zip
UI Tabs: fixed "colon in id bug", wrote more unit tests and refactored stuff afterwards
Diffstat (limited to 'tests')
-rw-r--r--tests/tabs.html22
-rw-r--r--tests/tabs.js139
2 files changed, 154 insertions, 7 deletions
diff --git a/tests/tabs.html b/tests/tabs.html
index 4fbc06354..a659050fc 100644
--- a/tests/tabs.html
+++ b/tests/tabs.html
@@ -11,13 +11,14 @@
<script type="text/javascript" src="qunit/testrunner.js"></script>
<script type="text/javascript" src="simulate/jquery.simulate.js"></script>
+ <script type="text/javascript" src="plugins/cookie/jquery.cookie.js"></script>
<script type="text/javascript" src="tabs.js"></script>
<style type="text/css">
-
-
-
+ .ui-tabs-hide {
+ display: none !important;
+ }
</style>
@@ -32,6 +33,7 @@
<ol id="tests"></ol>
<div id="main" style="position:absolute;top:-20000px">
+
<div id="tabs1">
<ul>
<li><a href="#fragment-1"><span>One</span></a></li>
@@ -51,6 +53,20 @@
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
</div>
+
+ <div id="tabs2">
+ <ul>
+ <li><a href="#colon:test"><span>One</span></a></li>
+ <li><a href="#inline-style"><span>Two</span></a></li>
+ </ul>
+ <div id="colon:test">
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
+ </div>
+ <div style="height: 300px;" id="inline-style">
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
+ </div>
+ </div>
+
</div>
</body>
diff --git a/tests/tabs.js b/tests/tabs.js
index 653b04f6f..51f582231 100644
--- a/tests/tabs.js
+++ b/tests/tabs.js
@@ -8,14 +8,145 @@
// Tabs Tests
-module("tabs");
+module('tabs');
-test("init", function() {
- expect(1);
+test('init', function() {
+ expect(4);
- el = $("#tabs1").tabs();
+ var el = $('#tabs1 > ul').tabs();
ok(true, '.tabs() called on element');
+
+ el.tabs('destroy').tabs({ selected: 1 });
+ equals( el.data('selected.tabs'), 1 );
+ equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 1, 'second tab active');
+ equals( $('div', '#tabs1').index( $('div.ui-tabs-hide', '#tabs1') ), 0, 'first panel should be hidden' );
+
});
+test('destroy', function() {
+ expect(0);
+
+});
+
+test("defaults", function() {
+
+ var expected = {
+ unselect: false,
+ event: 'click',
+ disabled: [],
+ cookie: null,
+ spinner: 'Loading&#8230;',
+ cache: false,
+ idPrefix: 'ui-tabs-',
+ ajaxOptions: null,
+ fx: null,
+ tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
+ panelTemplate: '<div></div>',
+ navClass: 'ui-tabs-nav',
+ selectedClass: 'ui-tabs-selected',
+ unselectClass: 'ui-tabs-unselect',
+ disabledClass: 'ui-tabs-disabled',
+ panelClass: 'ui-tabs-panel',
+ hideClass: 'ui-tabs-hide',
+ loadingClass: 'ui-tabs-loading'
+ };
+
+ var el = $("#tabs1").tabs();
+
+ for (var optionName in expected) {
+ var actual = el.data(optionName + '.tabs'), expects = expected[optionName];
+
+ if (optionName == 'disabled')
+ ok(expects.constructor == Array && !expects.length, optionName);
+ else
+ equals(actual, expects, optionName);
+
+ }
+
+});
+
+test('add', function() {
+ expect(0);
+
+});
+
+test('remove', function() {
+ expect(0);
+
+});
+
+test('enable', function() {
+ expect(0);
+
+});
+
+test('disable', function() {
+ expect(0);
+
+});
+
+test('select', function() {
+ expect(0);
+
+});
+
+test('load', function() {
+ expect(0);
+
+});
+
+test('url', function() {
+ expect(0);
+
+});
+
+test('cookie', function() {
+ expect(5);
+
+ var el = $('#tabs1 > ul');
+ var cookieName = 'ui-tabs-' + $.data(el[0]);
+ $.cookie(cookieName, null); // blank state
+ var cookie = function() {
+ return parseInt($.cookie(cookieName), 10);
+ };
+
+ el.tabs({ cookie: {} });
+ equals(cookie(), 0, 'initial cookie value, no cookie given');
+
+ el.tabs('destroy');
+ el.tabs({ selected: 1, cookie: {} });
+ equals(cookie(), 1, 'initial cookie value, given selected');
+
+ el.tabs('select', 2);
+ equals(cookie(), 2, 'cookie value after tabs select');
+
+ el.tabs('destroy');
+ $.cookie(cookieName, 1);
+ el.tabs({ cookie: {} });
+ equals(cookie(), 1, 'initial cookie value, from existing cookie');
+
+ el.tabs('destroy');
+ ok($.cookie(cookieName) === null, 'erase cookie after destroy');
+
+});
+
+// #???
+test('id containing colon', function() {
+ expect(4);
+
+ var el = $('#tabs2 > ul').tabs();
+ ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' );
+ ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' );
+
+ el.tabs('select', 1).tabs('select', 0);
+ ok( $('div.ui-tabs-panel:eq(0)', '#tabs2').is(':visible'), 'first panel should be visible' );
+ ok( $('div.ui-tabs-panel:eq(1)', '#tabs2').is(':hidden'), 'second panel should be hidden' );
+
+});
+
+// test('', function() {
+// expect(0);
+//
+// });
})(jQuery);
4/stable28'>backport/47924/stable28 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/.htaccess
blob: 190b414558b29b082a387509cc586418299ac843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80