mirror of
https://github.com/uxsolutions/bootstrap-datepicker.git
synced 2026-01-25 16:46:28 +00:00
Add tests for today button functionality
This commit is contained in:
parent
08f0c8f4dc
commit
8babfbd56b
@ -105,3 +105,85 @@ test('Startview: decade view (string)', function(){
|
||||
ok(picker.find('.datepicker-months').is(':not(:visible)'), 'Months view hidden');
|
||||
ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
|
||||
});
|
||||
|
||||
test('Today Button: today button not default', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':not(:visible)'), 'Today button not visible');
|
||||
});
|
||||
|
||||
test('Today Button: today visibility when enabled', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayBtn: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
picker.find('.datepicker-days thead th.switch').click();
|
||||
ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
|
||||
ok(picker.find('.datepicker-months tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
picker.find('.datepicker-months thead th.switch').click();
|
||||
ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
|
||||
ok(picker.find('.datepicker-years tfoot .today').is(':visible'), 'Today button visible');
|
||||
});
|
||||
|
||||
test('Today Button: data-api', function(){
|
||||
var input = $('<input data-date-today-btn="true" />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd'
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
});
|
||||
|
||||
test('Today Button: selects today\'s date', function(){
|
||||
var input = $('<input />')
|
||||
.appendTo('#qunit-fixture')
|
||||
.val('2012-03-05')
|
||||
.datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
todayBtn: true
|
||||
}),
|
||||
dp = input.data('datepicker'),
|
||||
picker = dp.picker,
|
||||
target;
|
||||
|
||||
input.focus();
|
||||
ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
|
||||
ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
|
||||
|
||||
target = picker.find('.datepicker-days tfoot .today');
|
||||
target.click();
|
||||
|
||||
var d = new Date(),
|
||||
today = new Date(d.getFullYear(), d.getMonth(), d.getDate())
|
||||
datesEqual(dp.viewDate, today);
|
||||
datesEqual(dp.date, today);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user