clear link in date input

This commit is contained in:
vitalets
2012-11-26 13:36:29 +04:00
parent 999bbe25df
commit 2438ea8da1
7 changed files with 89 additions and 9 deletions

@ -14,7 +14,7 @@ $(function () {
return dpg.formatDate(date, dpg.parseFormat(format), 'en');
}
asyncTest("popover should contain datepicker with value and save new entered date", function () {
asyncTest("container should contain datepicker with value and save new entered date", function () {
expect(9);
$.fn.editableform.types.date.defaults.datepicker.weekStart = 1;
@ -130,5 +130,47 @@ $(function () {
p.find('button[type=button]').click();
ok(!p.is(':visible'), 'popover closed');
});
asyncTest("clear button", function () {
var d = '15.05.1984',
e = $('<a href="#" data-type="date" data-pk="1" data-url="post-date-clear.php">'+d+'</a>').appendTo(fx).editable({
format: f,
clear: 'abc'
});
$.mockjax({
url: 'post-date-clear.php',
response: function(settings) {
equal(settings.data.value, '', 'submitted value correct');
}
});
equal(frmt(e.data('editable').value, 'dd.mm.yyyy'), d, 'value correct');
e.click();
var p = tip(e);
ok(p.find('.datepicker').is(':visible'), 'datepicker exists');
equal(frmt(e.data('editable').value, f), d, 'day set correct');
equal(p.find('td.day.active').text(), 15, 'day shown correct');
var clear = p.find('.editable-clear');
equal(clear.text(), 'abc', 'clear link shown');
//click clear
clear.click();
ok(!p.find('td.day.active').length, 'no active day');
p.find('form').submit();
setTimeout(function() {
ok(!p.is(':visible'), 'popover closed');
equal(e.data('editable').value, null, 'null saved to value');
equal(e.text(), e.data('editable').options.emptytext, 'empty text shown');
e.remove();
start();
}, timeout);
});
});