mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
complete base options tests, begin event tests
This commit is contained in:
parent
fc5f1c9156
commit
57485139b3
@ -15,6 +15,7 @@
|
||||
mocha.setup('bdd');
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="specs/events.js"></script>
|
||||
<script type="text/javascript" src="specs/options.js"></script>
|
||||
<script type="text/javascript" src="specs/static-methods.js"></script>
|
||||
<style type="text/css">
|
||||
|
||||
53
tests/specs/events.js
Normal file
53
tests/specs/events.js
Normal file
@ -0,0 +1,53 @@
|
||||
describe('Events', function () {
|
||||
var assert = chai.assert,
|
||||
expect = chai.expect,
|
||||
destroy = true,
|
||||
$span,
|
||||
$altInput,
|
||||
$input, dp;
|
||||
|
||||
before(function () {
|
||||
$input = $('<input>').appendTo('#container');
|
||||
$span = $('<span>').appendTo('#container');
|
||||
$altInput = $('<input class="alt-field">').appendTo('#container');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
if (dp && destroy) {
|
||||
dp.destroy();
|
||||
}
|
||||
|
||||
destroy = true;
|
||||
});
|
||||
|
||||
describe('onSelect', function () {
|
||||
it('should add callback when user selects date', function () {
|
||||
var date = new Date(2016,0,13);
|
||||
|
||||
dp = $input.datepicker({
|
||||
onSelect: function (fd, d, inst) {
|
||||
expect(fd).to.be.equal('13.01.2016');
|
||||
expect(d).to.be.instanceof(Date);
|
||||
expect(inst).to.be.instanceof(Datepicker);
|
||||
}
|
||||
}).data('datepicker');
|
||||
|
||||
dp.selectDate(date);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('onRenderCell', function () {
|
||||
it('should add callback when cell is rendered', function () {
|
||||
|
||||
dp = $input.datepicker({
|
||||
onRenderCell: function (d, type) {
|
||||
expect(d).to.be.instanceOf(Date);
|
||||
expect(type).to.be.equal('day');
|
||||
}
|
||||
}).data('datepicker');
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
@ -1,11 +1,11 @@
|
||||
var assert = chai.assert,
|
||||
expect = chai.expect,
|
||||
destroy = true,
|
||||
$altInput,
|
||||
$input, dp;
|
||||
|
||||
|
||||
describe('Options', function () {
|
||||
|
||||
var assert = chai.assert,
|
||||
expect = chai.expect,
|
||||
destroy = true,
|
||||
$altInput,
|
||||
$input, dp;
|
||||
|
||||
before(function () {
|
||||
$input = $('<input>').appendTo('#container');
|
||||
$altInput = $('<input class="alt-field">').appendTo('#container');
|
||||
@ -770,4 +770,28 @@ describe('Options', function () {
|
||||
expect($next.html()).to.be.equal('next');
|
||||
});
|
||||
});
|
||||
|
||||
describe('navTitles', function () {
|
||||
it('defines datepicker titles', function () {
|
||||
dp = $input.datepicker({
|
||||
navTitles: {
|
||||
days: 'Days',
|
||||
months: 'Months',
|
||||
years: 'Years'
|
||||
}
|
||||
}).data('datepicker');
|
||||
|
||||
var $title = $('.datepicker--nav-title', dp.$datepicker);
|
||||
expect($title.html()).to.have.string('Days');
|
||||
|
||||
dp.view = 'months';
|
||||
$title = $('.datepicker--nav-title', dp.$datepicker);
|
||||
expect($title.html()).to.have.string('Months');
|
||||
|
||||
dp.view = 'years';
|
||||
$title = $('.datepicker--nav-title', dp.$datepicker);
|
||||
expect($title.html()).to.have.string('Years');
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user