2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* tabs_options.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("tabs: options");
|
|
|
|
|
2009-02-03 13:37:54 +00:00
|
|
|
test('collapsible', function() {
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
el = $('#tabs1');
|
|
|
|
|
|
|
|
el.tabs({ collapsible: true });
|
2009-11-09 01:50:23 +00:00
|
|
|
equals(el.tabs('option', 'collapsible'), true, 'option set');
|
2009-02-03 13:37:54 +00:00
|
|
|
ok(el.is('.ui-tabs-collapsible'), 'extra class "ui-tabs-collapsible" attached');
|
2011-03-29 02:28:59 +00:00
|
|
|
|
|
|
|
el.tabs('option', 'active', false);
|
2009-02-03 13:37:54 +00:00
|
|
|
equals($('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden');
|
2011-03-29 02:28:59 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
el.tabs('option', 'collapsible', false);
|
2009-02-03 13:37:54 +00:00
|
|
|
ok(el.is(':not(.ui-tabs-collapsible)'), 'extra class "ui-tabs-collapsible" not attached');
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('disabled', function() {
|
2010-04-21 19:31:29 +00:00
|
|
|
expect(4);
|
|
|
|
|
|
|
|
el = $('#tabs1').tabs();
|
2011-02-06 19:49:42 +00:00
|
|
|
same(el.tabs('option', 'disabled'), false, "should not disable any tab by default");
|
2010-04-21 19:31:29 +00:00
|
|
|
|
|
|
|
el.tabs('option', 'disabled', [ 1 ]);
|
|
|
|
same(el.tabs('option', 'disabled'), [ 1 ], "should set property"); // everything else is being tested in methods module...
|
|
|
|
|
|
|
|
el.tabs('option', 'disabled', [ 0, 1 ]);
|
2011-02-06 19:49:42 +00:00
|
|
|
same(el.tabs('option', 'disabled'), [ 0, 1 ], "should disable given tabs, even selected one"); // ...
|
2010-04-21 19:31:29 +00:00
|
|
|
|
|
|
|
el.tabs('option', 'disabled', [ ]);
|
2011-02-06 19:49:42 +00:00
|
|
|
same(el.tabs('option', 'disabled'), false, "should not disable any tab"); // ...
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
2009-02-04 09:35:52 +00:00
|
|
|
test('event', function() {
|
2009-02-03 13:37:54 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test('fx', function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
2011-03-27 20:37:43 +00:00
|
|
|
test('active', function() {
|
2009-02-05 19:36:31 +00:00
|
|
|
expect(8);
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el = $('#tabs1').tabs();
|
2011-03-27 20:37:43 +00:00
|
|
|
equals(el.tabs('option', 'active'), 0, 'should be 0 by default');
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el.tabs('destroy');
|
2011-03-27 20:37:43 +00:00
|
|
|
el.tabs({ active: -1 });
|
|
|
|
equals(el.tabs('option', 'active'), -1, 'should be -1 for all tabs deactive');
|
|
|
|
equals( $('li.ui-tabs-selected', el).length, 0, 'no tab should be active' );
|
2009-02-03 13:37:54 +00:00
|
|
|
equals( $('div.ui-tabs-hide', '#tabs1').length, 3, 'all panels should be hidden' );
|
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el.tabs('destroy');
|
2011-03-27 20:37:43 +00:00
|
|
|
el.tabs({ active: null });
|
|
|
|
equals(el.tabs('option', 'active'), -1, 'should be -1 for all tabs deactive with value null (deprecated)');
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el.tabs('destroy');
|
2011-03-27 20:37:43 +00:00
|
|
|
el.tabs({ active: 1 });
|
|
|
|
equals(el.tabs('option', 'active'), 1, 'should be specified tab');
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el.tabs('destroy');
|
2011-03-27 20:37:43 +00:00
|
|
|
el.tabs({ active: 99 });
|
|
|
|
equals(el.tabs('option', 'active'), 0, 'active should default to zero if given value is out of index');
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2009-02-05 19:36:31 +00:00
|
|
|
el.tabs('destroy');
|
|
|
|
el.tabs({ collapsible: true });
|
2011-03-27 20:37:43 +00:00
|
|
|
el.tabs('option', 'active', 0);
|
|
|
|
equals(el.tabs('option', 'active'), 0, 'should not collapse tab if value is same as active');
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
2009-02-02 14:36:08 +00:00
|
|
|
})(jQuery);
|