mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
added tests for enable/disable
This commit is contained in:
parent
970ed9a67a
commit
73adda4146
@ -22,15 +22,17 @@ test('show', function() {
|
||||
uiObj = ui;
|
||||
}
|
||||
});
|
||||
ok(uiObj !== undefined, 'should fire show after init');
|
||||
equals(uiObj.tab, $('#tabs1 a')[0], 'should have tab as DOM anchor element');
|
||||
equals(uiObj.panel, $('#tabs1 div')[0], 'should have panel as DOM div element');
|
||||
equals(uiObj.index, 0, 'should have index');
|
||||
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() {
|
||||
|
||||
// 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');
|
||||
|
||||
@ -47,11 +49,36 @@ test('remove', function() {
|
||||
});
|
||||
|
||||
test('enable', function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
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() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
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);
|
||||
|
@ -37,18 +37,34 @@ test('destroy', function() {
|
||||
});
|
||||
|
||||
test('enable', function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
expect(2);
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
test('disable', function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
expect(4);
|
||||
|
||||
// normal
|
||||
el = $('#tabs1').tabs();
|
||||
el.tabs('disable', 1);
|
||||
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
|
||||
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');
|
||||
});
|
||||
|
||||
test('add', function() {
|
||||
expect(4);
|
||||
|
||||
el = $('#tabs1').tabs();
|
||||
el.tabs('add', "#new", 'New');
|
||||
el.tabs('add', '#new', 'New');
|
||||
|
||||
var added = $('li:last', el).simulate('mouseover');
|
||||
ok(added.is('.ui-state-hover'), 'should add mouseover handler to added tab');
|
||||
|
Loading…
Reference in New Issue
Block a user