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,126 +30,159 @@ test("widget method", function() {
|
|||||||
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('baseStructure', function() {
|
asyncTest('baseStructure', function() {
|
||||||
expect( 58 );
|
expect( 58 );
|
||||||
var header, title, table, thead, week, panel, inl, child,
|
var header, title, table, thead, week, panel, inl, child,
|
||||||
inp = TestHelpers.datepicker.init('#inp').focus(),
|
inp = TestHelpers.datepicker.init('#inp'),
|
||||||
dp = $('#ui-datepicker-div');
|
dp = $('#ui-datepicker-div');
|
||||||
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');
|
|
||||||
equal(dp.children().length, 2, 'Structure - child count');
|
|
||||||
|
|
||||||
header = dp.children(':first');
|
function step1() {
|
||||||
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
|
inp[0].focus();
|
||||||
equal(header.children().length, 3, 'Structure - header child count');
|
setTimeout(function() {
|
||||||
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link');
|
ok(dp.is(':visible'), 'Structure - datepicker visible');
|
||||||
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link');
|
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
|
||||||
|
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
|
||||||
|
equal(dp.children().length, 2, 'Structure - child count');
|
||||||
|
|
||||||
title = header.children(':last');
|
header = dp.children(':first');
|
||||||
ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division');
|
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
|
||||||
equal(title.children().length, 2, 'Structure - title child count');
|
equal(header.children().length, 3, 'Structure - header child count');
|
||||||
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text');
|
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link');
|
||||||
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text');
|
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link');
|
||||||
|
|
||||||
table = dp.children(':eq(1)');
|
title = header.children(':last');
|
||||||
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
|
ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division');
|
||||||
ok(table.children(':first').is('thead'), 'Structure - month table thead');
|
equal(title.children().length, 2, 'Structure - title child count');
|
||||||
thead = table.children(':first').children(':first');
|
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text');
|
||||||
ok(thead.is('tr'), 'Structure - month table title row');
|
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text');
|
||||||
equal(thead.find('th').length, 7, 'Structure - month table title cells');
|
|
||||||
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
|
|
||||||
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
|
|
||||||
week = table.children(':eq(1)').children(':first');
|
|
||||||
ok(week.is('tr'), 'Structure - month table week row');
|
|
||||||
equal(week.children().length, 7, 'Structure - week child count');
|
|
||||||
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
|
|
||||||
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
|
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
|
||||||
|
|
||||||
// Editable month/year and button panel
|
table = dp.children(':eq(1)');
|
||||||
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
|
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
|
||||||
inp.focus();
|
ok(table.children(':first').is('thead'), 'Structure - month table thead');
|
||||||
|
thead = table.children(':first').children(':first');
|
||||||
|
ok(thead.is('tr'), 'Structure - month table title row');
|
||||||
|
equal(thead.find('th').length, 7, 'Structure - month table title cells');
|
||||||
|
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
|
||||||
|
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
|
||||||
|
week = table.children(':eq(1)').children(':first');
|
||||||
|
ok(week.is('tr'), 'Structure - month table week row');
|
||||||
|
equal(week.children().length, 7, 'Structure - week child count');
|
||||||
|
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
|
||||||
|
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
|
||||||
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
|
|
||||||
title = dp.find('div.ui-datepicker-title');
|
step2();
|
||||||
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
|
});
|
||||||
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
|
}
|
||||||
|
|
||||||
panel = dp.children(':last');
|
function step2() {
|
||||||
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
|
// Editable month/year and button panel
|
||||||
equal(panel.children().length, 2, 'Structure - button panel child count');
|
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
|
||||||
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
|
inp.focus();
|
||||||
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
|
setTimeout(function() {
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
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');
|
||||||
|
|
||||||
// Multi-month 2
|
panel = dp.children(':last');
|
||||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
|
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
|
||||||
inp.focus();
|
equal(panel.children().length, 2, 'Structure - button panel child count');
|
||||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
|
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
|
||||||
equal(dp.children().length, 3, 'Structure multi [2] - child count');
|
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
|
||||||
child = dp.children(':first');
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
|
|
||||||
child = dp.children(':eq(1)');
|
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division');
|
|
||||||
child = dp.children(':eq(2)');
|
|
||||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break');
|
|
||||||
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
|
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
|
||||||
|
|
||||||
// Multi-month 3
|
step3();
|
||||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
|
});
|
||||||
inp.focus();
|
}
|
||||||
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');
|
|
||||||
|
|
||||||
// Multi-month [2, 2]
|
function step3() {
|
||||||
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]});
|
// Multi-month 2
|
||||||
inp.focus();
|
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
|
||||||
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
|
inp.focus();
|
||||||
equal(dp.children().length, 6, 'Structure multi [2,2] - child count');
|
setTimeout(function() {
|
||||||
child = dp.children(':first');
|
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division');
|
equal(dp.children().length, 3, 'Structure multi [2] - child count');
|
||||||
child = dp.children(':eq(1)');
|
child = dp.children(':first');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division');
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
|
||||||
child = dp.children(':eq(2)');
|
child = dp.children(':eq(1)');
|
||||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division');
|
||||||
child = dp.children(':eq(3)');
|
child = dp.children(':eq(2)');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division');
|
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break');
|
||||||
child = dp.children(':eq(4)');
|
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division');
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
child = dp.children(':eq(5)');
|
|
||||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
|
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
|
||||||
|
|
||||||
// Inline
|
step4();
|
||||||
inl = TestHelpers.datepicker.init('#inl');
|
});
|
||||||
dp = inl.children();
|
}
|
||||||
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
|
|
||||||
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
|
|
||||||
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
|
|
||||||
equal(dp.children().length, 2, 'Structure inline - child count');
|
|
||||||
header = dp.children(':first');
|
|
||||||
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
|
|
||||||
equal(header.children().length, 3, 'Structure inline - header child count');
|
|
||||||
table = dp.children(':eq(1)');
|
|
||||||
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
|
|
||||||
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
|
|
||||||
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
|
|
||||||
inl.datepicker('destroy');
|
|
||||||
|
|
||||||
// Inline multi-month
|
function step4() {
|
||||||
inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2});
|
// Multi-month 3
|
||||||
dp = inl.children();
|
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
|
||||||
ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
|
inp.focus();
|
||||||
equal(dp.children().length, 3, 'Structure inline multi - child count');
|
setTimeout(function() {
|
||||||
child = dp.children(':first');
|
ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division');
|
ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704');
|
||||||
child = dp.children(':eq(1)');
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division');
|
|
||||||
child = dp.children(':eq(2)');
|
step5();
|
||||||
ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break');
|
});
|
||||||
inl.datepicker('destroy');
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division');
|
||||||
|
child = dp.children(':eq(1)');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division');
|
||||||
|
child = dp.children(':eq(2)');
|
||||||
|
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
|
||||||
|
child = dp.children(':eq(3)');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division');
|
||||||
|
child = dp.children(':eq(4)');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division');
|
||||||
|
child = dp.children(':eq(5)');
|
||||||
|
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
|
||||||
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
|
|
||||||
|
// Inline
|
||||||
|
inl = TestHelpers.datepicker.init('#inl');
|
||||||
|
dp = inl.children();
|
||||||
|
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
|
||||||
|
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
|
||||||
|
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
|
||||||
|
equal(dp.children().length, 2, 'Structure inline - child count');
|
||||||
|
header = dp.children(':first');
|
||||||
|
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
|
||||||
|
equal(header.children().length, 3, 'Structure inline - header child count');
|
||||||
|
table = dp.children(':eq(1)');
|
||||||
|
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
|
||||||
|
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
|
||||||
|
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
|
||||||
|
inl.datepicker('destroy');
|
||||||
|
|
||||||
|
// Inline multi-month
|
||||||
|
inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2});
|
||||||
|
dp = inl.children();
|
||||||
|
ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
|
||||||
|
equal(dp.children().length, 3, 'Structure inline multi - child count');
|
||||||
|
child = dp.children(':first');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division');
|
||||||
|
child = dp.children(':eq(1)');
|
||||||
|
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division');
|
||||||
|
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() {
|
test('customStructure', function() {
|
||||||
|
@ -87,76 +87,114 @@ test('change', function() {
|
|||||||
equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
|
equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('invocation', function() {
|
asyncTest('invocation', function() {
|
||||||
expect( 29 );
|
expect( 29 );
|
||||||
var button, image,
|
var button, image,
|
||||||
inp = TestHelpers.datepicker.init('#inp'),
|
inp = TestHelpers.datepicker.init('#inp'),
|
||||||
dp = $('#ui-datepicker-div'),
|
dp = $('#ui-datepicker-div'),
|
||||||
body = $('body');
|
body = $('body');
|
||||||
// On focus
|
|
||||||
button = inp.siblings('button');
|
function step1() {
|
||||||
ok(button.length === 0, 'Focus - button absent');
|
// On focus
|
||||||
image = inp.siblings('img');
|
button = inp.siblings('button');
|
||||||
ok(image.length === 0, 'Focus - image absent');
|
ok(button.length === 0, 'Focus - button absent');
|
||||||
inp.focus();
|
image = inp.siblings('img');
|
||||||
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
ok(image.length === 0, 'Focus - image absent');
|
||||||
inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
|
inp[0].focus();
|
||||||
ok(!dp.is(':visible'), 'Focus - hidden on exit');
|
setTimeout(function() {
|
||||||
inp.focus();
|
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
||||||
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
|
||||||
body.simulate('mousedown', {});
|
ok(!dp.is(':visible'), 'Focus - hidden on exit');
|
||||||
ok(!dp.is(':visible'), 'Focus - hidden on external click');
|
inp[0].blur();
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
setTimeout(function() {
|
||||||
// On button
|
inp[0].focus();
|
||||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'});
|
setTimeout(function() {
|
||||||
ok(!dp.is(':visible'), 'Button - initially hidden');
|
ok(dp.is(':visible'), 'Focus - rendered on focus');
|
||||||
button = inp.siblings('button');
|
body.simulate('mousedown', {});
|
||||||
image = inp.siblings('img');
|
ok(!dp.is(':visible'), 'Focus - hidden on external click');
|
||||||
ok(button.length === 1, 'Button - button present');
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
ok(image.length === 0, 'Button - image absent');
|
|
||||||
equal(button.text(), 'Popup', 'Button - button text');
|
step2();
|
||||||
inp.focus();
|
});
|
||||||
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');
|
function step2() {
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
// On button
|
||||||
// On image button
|
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'});
|
||||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
|
ok(!dp.is(':visible'), 'Button - initially hidden');
|
||||||
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
|
button = inp.siblings('button');
|
||||||
ok(!dp.is(':visible'), 'Image button - initially hidden');
|
image = inp.siblings('img');
|
||||||
button = inp.siblings('button');
|
ok(button.length === 1, 'Button - button present');
|
||||||
ok(button.length === 0, 'Image button - button absent');
|
ok(image.length === 0, 'Button - image absent');
|
||||||
image = inp.siblings('img');
|
equal(button.text(), 'Popup', 'Button - button text');
|
||||||
ok(image.length === 1, 'Image button - image present');
|
inp[0].focus();
|
||||||
equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
|
setTimeout(function() {
|
||||||
equal(image.attr('title'), 'Cal', 'Image button - image text');
|
ok(!dp.is(':visible'), 'Button - not rendered on focus');
|
||||||
inp.focus();
|
button.click();
|
||||||
ok(!dp.is(':visible'), 'Image button - not rendered on focus');
|
ok(dp.is(':visible'), 'Button - rendered on button click');
|
||||||
image.click();
|
button.click();
|
||||||
ok(dp.is(':visible'), 'Image button - rendered on image click');
|
ok(!dp.is(':visible'), 'Button - hidden on second button click');
|
||||||
image.click();
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
ok(!dp.is(':visible'), 'Image button - hidden on second image click');
|
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
step3();
|
||||||
// On both
|
});
|
||||||
inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});
|
}
|
||||||
ok(!dp.is(':visible'), 'Both - initially hidden');
|
|
||||||
button = inp.siblings('button');
|
function step3() {
|
||||||
ok(button.length === 1, 'Both - button present');
|
// On image button
|
||||||
image = inp.siblings('img');
|
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
|
||||||
ok(image.length === 0, 'Both - image absent');
|
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
|
||||||
image = button.children('img');
|
ok(!dp.is(':visible'), 'Image button - initially hidden');
|
||||||
ok(image.length === 1, 'Both - button image present');
|
button = inp.siblings('button');
|
||||||
inp.focus();
|
ok(button.length === 0, 'Image button - button absent');
|
||||||
ok(dp.is(':visible'), 'Both - rendered on focus');
|
image = inp.siblings('img');
|
||||||
body.simulate('mousedown', {});
|
ok(image.length === 1, 'Image button - image present');
|
||||||
ok(!dp.is(':visible'), 'Both - hidden on external click');
|
equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
|
||||||
button.click();
|
equal(image.attr('title'), 'Cal', 'Image button - image text');
|
||||||
ok(dp.is(':visible'), 'Both - rendered on button click');
|
inp[0].focus();
|
||||||
button.click();
|
setTimeout(function() {
|
||||||
ok(!dp.is(':visible'), 'Both - hidden on second button click');
|
ok(!dp.is(':visible'), 'Image button - not rendered on focus');
|
||||||
inp.datepicker('hide').datepicker('destroy');
|
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');
|
||||||
|
button = inp.siblings('button');
|
||||||
|
ok(button.length === 1, 'Both - button present');
|
||||||
|
image = inp.siblings('img');
|
||||||
|
ok(image.length === 0, 'Both - image absent');
|
||||||
|
image = button.children('img');
|
||||||
|
ok(image.length === 1, 'Both - button image present');
|
||||||
|
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');
|
||||||
|
button.click();
|
||||||
|
ok(dp.is(':visible'), 'Both - rendered on button click');
|
||||||
|
button.click();
|
||||||
|
ok(!dp.is(':visible'), 'Both - hidden on second button click');
|
||||||
|
inp.datepicker('hide').datepicker('destroy');
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
step1();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('otherMonths', function() {
|
test('otherMonths', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user