jquery-ui/tests/unit/tabs/tabs_events.js

85 lines
2.0 KiB
JavaScript
Raw Normal View History

/*
* tabs_events.js
*/
(function($) {
module("tabs: events");
test('select', function() {
ok(false, "missing test - untested code is broken code.");
});
test('load', function() {
ok(false, "missing test - untested code is broken code.");
});
test('show', function() {
expect(4);
var uiObj;
el = $('#tabs1').tabs({
show: function(event, ui) {
uiObj = ui;
}
});
2010-04-19 18:38:04 +00:00
ok(uiObj !== undefined, 'trigger callback after initialization');
equals(uiObj.tab, $('a', el)[0], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[0], 'contain panel as DOM div element');
equals(uiObj.index, 0, 'contain index');
});
test('add', function() {
2010-04-19 18:38:04 +00:00
// TODO move to methods, not at all event related...
var el = $('<div id="tabs"><ul></ul></div>').tabs();
equals(el.tabs('option', 'selected'), -1, 'Initially empty, no selected tab');
el.tabs('add', '#test1', 'Test 1');
equals(el.tabs('option', 'selected'), 0, 'First tab added should be auto selected');
el.tabs('add', '#test2', 'Test 2');
equals(el.tabs('option', 'selected'), 0, 'Second tab added should not be auto selected');
});
test('remove', function() {
ok(false, "missing test - untested code is broken code.");
});
test('enable', function() {
2010-04-19 18:38:04 +00:00
expect(4);
var uiObj;
el = $('#tabs1').tabs({
disabled: [ 0, 1 ],
enable: function (event, ui) {
uiObj = ui;
}
});
el.tabs('enable', 1);
ok(uiObj !== undefined, 'trigger callback');
equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element');
equals(uiObj.index, 1, 'contain index');
});
test('disable', function() {
2010-04-19 18:38:04 +00:00
expect(4);
var uiObj;
el = $('#tabs1').tabs({
disable: function (event, ui) {
uiObj = ui;
}
});
el.tabs('disable', 1);
ok(uiObj !== undefined, 'trigger callback');
equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element');
equals(uiObj.index, 1, 'contain index');
});
})(jQuery);