aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-03-21 11:30:11 -0400
committerScott González <scott.gonzalez@gmail.com>2011-03-21 11:30:11 -0400
commit923b5b67b9e23b58b4ce184c8c0de343d5b179be (patch)
tree0cf2c9f1ca32a12a2b7178b2b1ec65c655aac2ea /tests/unit
parent52fd686f08d9ff1fab8b7fd92384e33bc26465da (diff)
parent710d7620e7f713677a21fc5a8572581250499dd3 (diff)
downloadjquery-ui-923b5b67b9e23b58b4ce184c8c0de343d5b179be.tar.gz
jquery-ui-923b5b67b9e23b58b4ce184c8c0de343d5b179be.zip
Merge branch 'tabs_4386' of https://github.com/petersendidit/jquery-ui
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/tabs/tabs_defaults.js2
-rw-r--r--tests/unit/tabs/tabs_methods.js46
-rw-r--r--tests/unit/tabs/tabs_options.js7
3 files changed, 44 insertions, 11 deletions
diff --git a/tests/unit/tabs/tabs_defaults.js b/tests/unit/tabs/tabs_defaults.js
index d94fbda92..ef93c69ee 100644
--- a/tests/unit/tabs/tabs_defaults.js
+++ b/tests/unit/tabs/tabs_defaults.js
@@ -9,7 +9,7 @@ var tabs_defaults = {
collapsible: false,
cookie: null,
disable: null,
- disabled: [],
+ disabled: false,
enable: null,
event: "click",
fx: null,
diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js
index bfd9d7713..0209af697 100644
--- a/tests/unit/tabs/tabs_methods.js
+++ b/tests/unit/tabs/tabs_methods.js
@@ -73,16 +73,32 @@ test('destroy', function() {
});
test('enable', function() {
- expect(2);
+ expect(8);
el = $('#tabs1').tabs({ disabled: [ 0, 1 ] });
el.tabs("enable", 1);
ok( $('li:eq(1)', el).is(':not(.ui-state-disabled)'), 'remove class from li');
- same(el.tabs('option', 'disabled'), [ ], 'update property');
+ same(el.tabs('option', 'disabled'), [ 0 ], 'update property');
+
+ // enable all tabs
+ el.tabs({ disabled: [ 0, 1 ] });
+ el.tabs("enable");
+ ok( !$('li.ui-state-disabled', el).length, 'enable all');
+ same(el.tabs('option', 'disabled'), false, 'update property');
+
+ el.tabs('destroy');
+ // enable all tabs one by one
+ el.tabs({ disabled: [ 1, 2 ] });
+ el.tabs("enable", 1);
+ ok( $('li:eq(1)', el).is(':not(.ui-state-disabled)'), 'remove class from li');
+ same(el.tabs('option', 'disabled'), [ 2 ], 'update property');
+ el.tabs("enable", 2);
+ ok( $('li:eq(2)', el).is(':not(.ui-state-disabled)'), 'remove class from li');
+ same( el.tabs('option', 'disabled'), false, 'set to false');
});
test('disable', function() {
- expect(4);
+ expect(12);
// normal
el = $('#tabs1').tabs();
@@ -90,10 +106,28 @@ test('disable', function() {
ok( $('li:eq(1)', el).is('.ui-state-disabled'), 'add class to li');
same(el.tabs('option', 'disabled'), [ 1 ], 'update disabled property');
- // attempt to disable selected has no effect
+ // disable selected
el.tabs('disable', 0);
- ok( $('li:eq(0)', el).is(':not(.ui-state-disabled)'), 'not add class to li');
- same(el.tabs('option', 'disabled'), [ 1 ], 'not update property');
+ ok( $('li:eq(0)', el).is('.ui-state-disabled'), 'add class to selected li');
+ same(el.tabs('option', 'disabled'), [ 0, 1 ], 'update disabled property');
+
+ // disable all tabs
+ el.tabs('disable');
+ same( $('li.ui-state-disabled', el).length, 3, 'disable all');
+ same(el.tabs('option', 'disabled'), true, 'set to true');
+
+ el.tabs("destroy");
+ // disable all tabs one by one
+ el.tabs();
+ el.tabs('disable', 0);
+ ok( $('li:eq(0)', el).is('.ui-state-disabled'), 'add class to li');
+ same(el.tabs('option', 'disabled'), [ 0 ], 'update disabled property');
+ el.tabs('disable', 1);
+ ok( $('li:eq(1)', el).is('.ui-state-disabled'), 'add class to li');
+ same(el.tabs('option', 'disabled'), [ 0, 1 ], 'update disabled property');
+ el.tabs('disable', 2);
+ ok( $('li:eq(2)', el).is('.ui-state-disabled'), 'add class to li');
+ same(el.tabs('option', 'disabled'), true, 'set to true');
});
test('add', function() {
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index 4fb802b66..1c621ac28 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -67,17 +67,16 @@ test('disabled', function() {
expect(4);
el = $('#tabs1').tabs();
- same(el.tabs('option', 'disabled'), [ ], "should not disable any tab by default");
+ same(el.tabs('option', 'disabled'), false, "should not disable any tab by default");
el.tabs('option', 'disabled', [ 1 ]);
same(el.tabs('option', 'disabled'), [ 1 ], "should set property"); // everything else is being tested in methods module...
- // FIXME bug... property needs to be [ 1 ], since selected tab cannot be disabled!
el.tabs('option', 'disabled', [ 0, 1 ]);
- same(el.tabs('option', 'disabled'), [ 1 ], "should disable given tabs but not selected one"); // ...
+ same(el.tabs('option', 'disabled'), [ 0, 1 ], "should disable given tabs, even selected one"); // ...
el.tabs('option', 'disabled', [ ]);
- same(el.tabs('option', 'disabled'), [ ], "should not disable any tab"); // ...
+ same(el.tabs('option', 'disabled'), false, "should not disable any tab"); // ...
});
test('event', function() {