2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* tabs_events.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("tabs: events");
|
|
|
|
|
2009-02-03 13:37:54 +00:00
|
|
|
test('select', function() {
|
2011-02-08 00:32:32 +00:00
|
|
|
expect(7);
|
|
|
|
|
|
|
|
var eventObj;
|
2010-07-21 00:51:09 +00:00
|
|
|
el = $('#tabs1').tabs({
|
|
|
|
select: function(event, ui) {
|
|
|
|
ok(true, 'select triggered after initialization');
|
|
|
|
equals(this, el[0], "context of callback");
|
|
|
|
equals(event.type, 'tabsselect', 'event type in callback');
|
|
|
|
equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
|
|
|
|
equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
|
|
|
|
equals(ui.index, 1, 'contain index');
|
2011-02-08 00:32:32 +00:00
|
|
|
evenObj = event;
|
2010-07-21 00:51:09 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
el.tabs('select', 1);
|
2011-02-08 00:32:32 +00:00
|
|
|
|
|
|
|
el.find( "li:eq(1) a" ).simulate( "click" );
|
|
|
|
equals( evenObj.originalEvent.type, "click", "select triggered by click" );
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('load', function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test('show', function() {
|
2011-02-08 00:32:32 +00:00
|
|
|
expect(5);
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2011-02-08 00:32:32 +00:00
|
|
|
var uiObj, eventObj;
|
2009-02-03 13:37:54 +00:00
|
|
|
el = $('#tabs1').tabs({
|
|
|
|
show: function(event, ui) {
|
|
|
|
uiObj = ui;
|
2011-02-08 00:32:32 +00:00
|
|
|
eventObj = event;
|
2009-02-03 13:37:54 +00:00
|
|
|
}
|
|
|
|
});
|
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');
|
|
|
|
|
2011-02-08 00:32:32 +00:00
|
|
|
el.find( "li:eq(1) a" ).simulate( "click" );
|
|
|
|
equals( eventObj.originalEvent.type, "click", "show triggered by click" );
|
|
|
|
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('add', function() {
|
2009-12-31 13:43:54 +00:00
|
|
|
|
2010-04-19 18:38:04 +00:00
|
|
|
// TODO move to methods, not at all event related...
|
|
|
|
|
2009-12-31 13:43:54 +00:00
|
|
|
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');
|
|
|
|
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
2009-02-03 13:37:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|