Skip to content

Commit 008def0

Browse files
carhartlscottgonzalez
carhartl
authored andcommitted
added tests for disabled property
1 parent a4488af commit 008def0

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

tests/unit/tabs/tabs_options.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test('collapsible', function() {
2525
equals($('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden');
2626
el.tabs('option', 'collapsible', false);
2727
ok(el.is(':not(.ui-tabs-collapsible)'), 'extra class "ui-tabs-collapsible" not attached');
28-
28+
2929
});
3030

3131
test('cookie', function() {
@@ -47,24 +47,37 @@ test('cookie', function() {
4747

4848
el.tabs('select', 2);
4949
equals(cookie(), 2, 'cookie value updated after select');
50-
50+
5151
el.tabs('destroy');
5252
$.cookie(cookieName, 1);
5353
el.tabs({ cookie: cookieObj });
5454
equals(cookie(), 1, 'initial cookie value, from existing cookie');
55-
55+
5656
el.tabs('destroy');
5757
el.tabs({ cookie: cookieObj, collapsible: true });
5858
el.tabs('select', 0);
5959
equals(cookie(), -1, 'cookie value for all tabs unselected');
60-
60+
6161
el.tabs('destroy');
6262
ok($.cookie(cookieName) === null, 'erase cookie after destroy');
6363

6464
});
6565

6666
test('disabled', function() {
67-
ok(false, "missing test - untested code is broken code.");
67+
expect(4);
68+
69+
el = $('#tabs1').tabs();
70+
same(el.tabs('option', 'disabled'), [ ], "should not disable any tab by default");
71+
72+
el.tabs('option', 'disabled', [ 1 ]);
73+
same(el.tabs('option', 'disabled'), [ 1 ], "should set property"); // everything else is being tested in methods module...
74+
75+
// FIXME bug... property needs to be [ 1 ], since selected tab cannot be disabled!
76+
el.tabs('option', 'disabled', [ 0, 1 ]);
77+
same(el.tabs('option', 'disabled'), [ 1 ], "should disable given tabs but not selected one"); // ...
78+
79+
el.tabs('option', 'disabled', [ ]);
80+
same(el.tabs('option', 'disabled'), [ ], "should not disable any tab"); // ...
6881
});
6982

7083
test('event', function() {
@@ -85,10 +98,10 @@ test('panelTemplate', function() {
8598

8699
test('selected', function() {
87100
expect(8);
88-
101+
89102
el = $('#tabs1').tabs();
90103
equals(el.tabs('option', 'selected'), 0, 'should be 0 by default');
91-
104+
92105
el.tabs('destroy');
93106
el.tabs({ selected: -1 });
94107
equals(el.tabs('option', 'selected'), -1, 'should be -1 for all tabs unselected');
@@ -98,15 +111,15 @@ test('selected', function() {
98111
el.tabs('destroy');
99112
el.tabs({ selected: null });
100113
equals(el.tabs('option', 'selected'), -1, 'should be -1 for all tabs unselected with value null (deprecated)');
101-
114+
102115
el.tabs('destroy');
103116
el.tabs({ selected: 1 });
104117
equals(el.tabs('option', 'selected'), 1, 'should be specified tab');
105-
118+
106119
el.tabs('destroy');
107120
el.tabs({ selected: 99 });
108121
equals(el.tabs('option', 'selected'), 0, 'selected should default to zero if given value is out of index');
109-
122+
110123
el.tabs('destroy');
111124
el.tabs({ collapsible: true });
112125
el.tabs('option', 'selected', 0);

0 commit comments

Comments
 (0)