mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Datepicker tests: Handle async focus in IE.
This commit is contained in:
parent
694987f2f7
commit
28fcef5e9e
@ -30,11 +30,15 @@ test("widget method", function() {
|
||||
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
||||
});
|
||||
|
||||
test('baseStructure', function() {
|
||||
asyncTest('baseStructure', function() {
|
||||
expect( 58 );
|
||||
var header, title, table, thead, week, panel, inl, child,
|
||||
inp = TestHelpers.datepicker.init('#inp').focus(),
|
||||
inp = TestHelpers.datepicker.init('#inp'),
|
||||
dp = $('#ui-datepicker-div');
|
||||
|
||||
function step1() {
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Structure - datepicker visible');
|
||||
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
|
||||
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
|
||||
@ -67,10 +71,15 @@ test('baseStructure', function() {
|
||||
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step2();
|
||||
});
|
||||
}
|
||||
|
||||
function step2() {
|
||||
// Editable month/year and button panel
|
||||
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
|
||||
inp.focus();
|
||||
|
||||
setTimeout(function() {
|
||||
title = dp.find('div.ui-datepicker-title');
|
||||
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
|
||||
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
|
||||
@ -82,9 +91,15 @@ test('baseStructure', function() {
|
||||
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step3();
|
||||
});
|
||||
}
|
||||
|
||||
function step3() {
|
||||
// Multi-month 2
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
|
||||
equal(dp.children().length, 3, 'Structure multi [2] - child count');
|
||||
child = dp.children(':first');
|
||||
@ -96,16 +111,28 @@ test('baseStructure', function() {
|
||||
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step4();
|
||||
});
|
||||
}
|
||||
|
||||
function step4() {
|
||||
// Multi-month 3
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3');
|
||||
ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step5();
|
||||
});
|
||||
}
|
||||
|
||||
function step5() {
|
||||
// Multi-month [2, 2]
|
||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]});
|
||||
inp.focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
|
||||
equal(dp.children().length, 6, 'Structure multi [2,2] - child count');
|
||||
child = dp.children(':first');
|
||||
@ -150,6 +177,12 @@ test('baseStructure', function() {
|
||||
child = dp.children(':eq(2)');
|
||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break');
|
||||
inl.datepicker('destroy');
|
||||
|
||||
start();
|
||||
});
|
||||
}
|
||||
|
||||
step1();
|
||||
});
|
||||
|
||||
test('customStructure', function() {
|
||||
|
@ -87,26 +87,40 @@ test('change', function() {
|
||||
equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
|
||||
});
|
||||
|
||||
test('invocation', function() {
|
||||
asyncTest('invocation', function() {
|
||||
expect( 29 );
|
||||
var button, image,
|
||||
inp = TestHelpers.datepicker.init('#inp'),
|
||||
dp = $('#ui-datepicker-div'),
|
||||
body = $('body');
|
||||
|
||||
function step1() {
|
||||
// On focus
|
||||
button = inp.siblings('button');
|
||||
ok(button.length === 0, 'Focus - button absent');
|
||||
image = inp.siblings('img');
|
||||
ok(image.length === 0, 'Focus - image absent');
|
||||
inp.focus();
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
||||
inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
|
||||
ok(!dp.is(':visible'), 'Focus - hidden on exit');
|
||||
inp.focus();
|
||||
inp[0].blur();
|
||||
setTimeout(function() {
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
||||
body.simulate('mousedown', {});
|
||||
ok(!dp.is(':visible'), 'Focus - hidden on external click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step2();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function step2() {
|
||||
// On button
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'});
|
||||
ok(!dp.is(':visible'), 'Button - initially hidden');
|
||||
@ -115,13 +129,20 @@ test('invocation', function() {
|
||||
ok(button.length === 1, 'Button - button present');
|
||||
ok(image.length === 0, 'Button - image absent');
|
||||
equal(button.text(), 'Popup', 'Button - button text');
|
||||
inp.focus();
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(!dp.is(':visible'), 'Button - not rendered on focus');
|
||||
button.click();
|
||||
ok(dp.is(':visible'), 'Button - rendered on button click');
|
||||
button.click();
|
||||
ok(!dp.is(':visible'), 'Button - hidden on second button click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step3();
|
||||
});
|
||||
}
|
||||
|
||||
function step3() {
|
||||
// On image button
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
|
||||
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
|
||||
@ -132,13 +153,20 @@ test('invocation', function() {
|
||||
ok(image.length === 1, 'Image button - image present');
|
||||
equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
|
||||
equal(image.attr('title'), 'Cal', 'Image button - image text');
|
||||
inp.focus();
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(!dp.is(':visible'), 'Image button - not rendered on focus');
|
||||
image.click();
|
||||
ok(dp.is(':visible'), 'Image button - rendered on image click');
|
||||
image.click();
|
||||
ok(!dp.is(':visible'), 'Image button - hidden on second image click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
step4();
|
||||
});
|
||||
}
|
||||
|
||||
function step4() {
|
||||
// On both
|
||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});
|
||||
ok(!dp.is(':visible'), 'Both - initially hidden');
|
||||
@ -148,7 +176,10 @@ test('invocation', function() {
|
||||
ok(image.length === 0, 'Both - image absent');
|
||||
image = button.children('img');
|
||||
ok(image.length === 1, 'Both - button image present');
|
||||
inp.focus();
|
||||
inp[0].blur();
|
||||
setTimeout(function() {
|
||||
inp[0].focus();
|
||||
setTimeout(function() {
|
||||
ok(dp.is(':visible'), 'Both - rendered on focus');
|
||||
body.simulate('mousedown', {});
|
||||
ok(!dp.is(':visible'), 'Both - hidden on external click');
|
||||
@ -157,6 +188,13 @@ test('invocation', function() {
|
||||
button.click();
|
||||
ok(!dp.is(':visible'), 'Both - hidden on second button click');
|
||||
inp.datepicker('hide').datepicker('destroy');
|
||||
|
||||
start();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
step1();
|
||||
});
|
||||
|
||||
test('otherMonths', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user