datatables.net-datetime 1.0.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/{dateTime.scss → dataTables.dateTime.scss} +15 -0
- package/dist/dataTables.dateTime.css +218 -0
- package/{js/dateTime.js → dist/dataTables.dateTime.js} +191 -51
- package/dist/dataTables.dateTime.min.css +1 -0
- package/dist/dataTables.dateTime.min.js +43 -0
- package/docs/api/DateTime.use().xml +32 -0
- package/docs/api/destroy().xml +28 -0
- package/docs/api/errorMsg().xml +52 -0
- package/docs/api/hide().xml +36 -0
- package/docs/api/max().xml +35 -0
- package/docs/api/min().xml +35 -0
- package/docs/api/owns().xml +30 -0
- package/docs/api/val().xml +44 -0
- package/docs/option/buttons.clear.xml +27 -0
- package/docs/option/buttons.today.xml +29 -0
- package/docs/option/buttons.xml +28 -0
- package/docs/option/disableDays.xml +45 -0
- package/docs/option/firstDay.xml +34 -0
- package/docs/option/format.xml +31 -0
- package/docs/option/hoursAvailable.xml +36 -0
- package/docs/option/i18n.amPm.xml +32 -0
- package/docs/option/i18n.clear.xml +28 -0
- package/docs/option/i18n.hours.xml +33 -0
- package/docs/option/i18n.minutes.xml +33 -0
- package/docs/option/i18n.months.xml +32 -0
- package/docs/option/i18n.next.xml +32 -0
- package/docs/option/i18n.previous.xml +32 -0
- package/docs/option/i18n.seconds.xml +33 -0
- package/docs/option/i18n.today.xml +28 -0
- package/docs/option/i18n.unknown.xml +32 -0
- package/docs/option/i18n.weekdays.xml +32 -0
- package/docs/option/i18n.xml +37 -0
- package/docs/option/locale.xml +31 -0
- package/docs/option/maxDate.xml +51 -0
- package/docs/option/minDate.xml +52 -0
- package/docs/option/minutesAvailable.xml +36 -0
- package/docs/option/onChange.xml +38 -0
- package/docs/option/secondsAvailable.xml +36 -0
- package/docs/option/showWeekNumber.xml +30 -0
- package/docs/option/yearRange.xml +35 -0
- package/examples/index.xml +12 -0
- package/examples/initialisation/buttons.xml +38 -0
- package/examples/initialisation/datetime.xml +30 -0
- package/examples/initialisation/dayjs.xml +34 -0
- package/examples/initialisation/hidden.xml +28 -0
- package/examples/initialisation/i18n.xml +37 -0
- package/examples/initialisation/index.xml +12 -0
- package/examples/initialisation/jquery.xml +28 -0
- package/examples/initialisation/luxon.xml +29 -0
- package/examples/initialisation/moment.xml +29 -0
- package/examples/initialisation/simple.xml +30 -0
- package/examples/integration/datatables.xml +74 -0
- package/examples/integration/form.xml +65 -0
- package/gulpfile.js +3 -3
- package/js/{dateTime.d.ts → dataTables.dateTime.d.ts} +0 -1
- package/{dist/dateTime.js → js/dataTables.dateTime.js} +191 -51
- package/license.txt +9 -0
- package/make.sh +50 -0
- package/nuget.nuspec +20 -0
- package/package.json +6 -4
- package/readme.md +3 -1
- package/test/api/dateTime.destroy().js +49 -0
- package/test/api/dateTime.errorMsg().js +52 -0
- package/test/api/dateTime.hide().js +49 -0
- package/test/api/dateTime.max().js +86 -0
- package/test/api/dateTime.min().js +85 -0
- package/test/api/dateTime.owns().js +53 -0
- package/test/api/dateTime.val().js +70 -0
- package/test/options/dateTime.YearRange.js +51 -0
- package/test/options/dateTime.disableDays.js +46 -0
- package/test/options/dateTime.firstDay.js +33 -0
- package/test/options/dateTime.format.js +85 -0
- package/test/options/dateTime.i18n.amPm.js +35 -0
- package/test/options/dateTime.i18n.hours.js +33 -0
- package/test/options/dateTime.i18n.minutes.js +33 -0
- package/test/options/dateTime.i18n.months.js +33 -0
- package/test/options/dateTime.i18n.next.js +31 -0
- package/test/options/dateTime.i18n.previous.js +31 -0
- package/test/options/dateTime.i18n.seconds.js +33 -0
- package/test/options/dateTime.i18n.unknown.js +33 -0
- package/test/options/dateTime.i18n.weekdays.js +30 -0
- package/test/options/dateTime.init.js +54 -0
- package/test/options/dateTime.maxDate.js +66 -0
- package/test/options/dateTime.minDate.js +66 -0
- package/test/options/dateTime.onChange.js +130 -0
- package/test/options/dateTime.showWeekNumber.js +36 -0
- package/dist/dateTime.css +0 -168
- package/examples/basic.html +0 -26
- package/examples/datetime.html +0 -29
- package/examples/dayjs.html +0 -32
- package/examples/hidden.html +0 -26
- package/examples/jquery.html +0 -26
- package/examples/moment.html +0 -29
- package/examples/right.html +0 -39
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
describe('dateTime - i18n - minutes', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Default', function () {
|
|
10
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
11
|
+
format: 'HH:mm'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
$('#test').click();
|
|
15
|
+
|
|
16
|
+
expect($('.dt-datetime-minutes thead').text()).toBe('Minute');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
dt.html('input');
|
|
20
|
+
it('Change', function () {
|
|
21
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
22
|
+
format: 'HH:mm',
|
|
23
|
+
i18n: {
|
|
24
|
+
minutes: 'test'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
$('#test').click();
|
|
29
|
+
|
|
30
|
+
expect($('.dt-datetime-minutes thead').text()).toBe('test');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
describe('dateTime - i18n - months', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Default', function () {
|
|
10
|
+
let el = new DateTime(document.getElementById('test'));
|
|
11
|
+
|
|
12
|
+
$('#test').click();
|
|
13
|
+
|
|
14
|
+
expect($('.dt-datetime-month').text()).toBe(
|
|
15
|
+
'JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember'
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
dt.html('input');
|
|
20
|
+
it('Change', function () {
|
|
21
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
22
|
+
format: 'HH:mm',
|
|
23
|
+
i18n: {
|
|
24
|
+
months: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
$('#test').click();
|
|
29
|
+
|
|
30
|
+
expect($('.dt-datetime-month').text()).toBe('123456789101112');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
describe('dateTime - i18n - next', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// DD-1869
|
|
8
|
+
describe('Functional tests', function () {
|
|
9
|
+
dt.html('input');
|
|
10
|
+
it('Default', function () {
|
|
11
|
+
let el = new DateTime(document.getElementById('test'));
|
|
12
|
+
|
|
13
|
+
$('#test').click();
|
|
14
|
+
|
|
15
|
+
expect($('.dt-datetime-iconRight').text()).toBe('Next');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
dt.html('input');
|
|
19
|
+
it('Change', function () {
|
|
20
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
21
|
+
i18n: {
|
|
22
|
+
next: 'test'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
$('#test').click();
|
|
27
|
+
|
|
28
|
+
expect($('.dt-datetime-iconRight').text()).toBe('test');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
describe('dateTime - i18n - previous', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// DD-1869
|
|
8
|
+
describe('Functional tests', function () {
|
|
9
|
+
dt.html('input');
|
|
10
|
+
it('Default', function () {
|
|
11
|
+
let el = new DateTime(document.getElementById('test'));
|
|
12
|
+
|
|
13
|
+
$('#test').click();
|
|
14
|
+
|
|
15
|
+
expect($('.dt-datetime-iconLeft').text()).toBe('Previous');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
dt.html('input');
|
|
19
|
+
it('Change', function () {
|
|
20
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
21
|
+
i18n: {
|
|
22
|
+
previous: 'test'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
$('#test').click();
|
|
27
|
+
|
|
28
|
+
expect($('.dt-datetime-iconLeft').text()).toBe('test');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
describe('dateTime - i18n - seconds', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Default', function () {
|
|
10
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
11
|
+
format: 'HH:mm:ss'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
$('#test').click();
|
|
15
|
+
|
|
16
|
+
expect($('.dt-datetime-seconds thead').text()).toBe('Second');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
dt.html('input');
|
|
20
|
+
it('Change', function () {
|
|
21
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
22
|
+
format: 'HH:mm:ss',
|
|
23
|
+
i18n: {
|
|
24
|
+
seconds: 'test'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
$('#test').click();
|
|
29
|
+
|
|
30
|
+
expect($('.dt-datetime-seconds thead').text()).toBe('test');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
describe('dateTime - i18n - unknown', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// DD-1870
|
|
8
|
+
describe('Functional tests', function () {
|
|
9
|
+
dt.html('input');
|
|
10
|
+
// it('Default', function () {
|
|
11
|
+
// let el = new DateTime(document.getElementById('test'), {
|
|
12
|
+
// format: 'HH:mm:ss'
|
|
13
|
+
// });
|
|
14
|
+
|
|
15
|
+
// $('#test').click();
|
|
16
|
+
|
|
17
|
+
// expect($('.dt-datetime-seconds thead').text()).toBe('Second');
|
|
18
|
+
// });
|
|
19
|
+
|
|
20
|
+
// dt.html('input');
|
|
21
|
+
// it('Change', function () {
|
|
22
|
+
// let el = new DateTime(document.getElementById('test'), {
|
|
23
|
+
// i18n: {
|
|
24
|
+
// unknown: 'test'
|
|
25
|
+
// }
|
|
26
|
+
// });
|
|
27
|
+
|
|
28
|
+
// $('#test').click();
|
|
29
|
+
|
|
30
|
+
// expect($('.dt-datetime-seconds thead').text()).toBe('test');
|
|
31
|
+
// });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
describe('dateTime - i18n - weekdays', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Default', function () {
|
|
10
|
+
let el = new DateTime(document.getElementById('test'));
|
|
11
|
+
|
|
12
|
+
$('#test').click();
|
|
13
|
+
|
|
14
|
+
expect($('.dt-datetime-calendar thead').text()).toBe('MonTueWedThuFriSatSun');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
dt.html('input');
|
|
18
|
+
it('Change', function () {
|
|
19
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
20
|
+
i18n: {
|
|
21
|
+
weekdays: ['1', '2', '3', '4', '5', '6', '7']
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
$('#test').click();
|
|
26
|
+
|
|
27
|
+
expect($('.dt-datetime-calendar thead').text()).toBe('2345671');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
describe('dateTime - basic initialisation', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Standard initialsiation', function () {
|
|
10
|
+
new DateTime(document.getElementById('test'), {});
|
|
11
|
+
|
|
12
|
+
expect($('.dt-datetime').length).toBe(0);
|
|
13
|
+
$('#test').click();
|
|
14
|
+
expect($('.dt-datetime').length).toBe(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
dt.html('input');
|
|
18
|
+
it('Standard initialsiation on control with value', function () {
|
|
19
|
+
new DateTime(document.getElementById('value'), {});
|
|
20
|
+
expect($('#value').val()).toBe('2021-10-20');
|
|
21
|
+
});
|
|
22
|
+
it('... value in the picker', function () {
|
|
23
|
+
$('#value').click();
|
|
24
|
+
expect($('.dt-datetime-calendar td.selected').text()).toBe('20');
|
|
25
|
+
expect($('.dt-datetime-month').val()).toBe('9');
|
|
26
|
+
expect($('.dt-datetime-year').val()).toBe('2021');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
dt.html('input');
|
|
30
|
+
it('Standard initialsiation with options', function () {
|
|
31
|
+
new DateTime(document.getElementById('test'), {firstDay: 3});
|
|
32
|
+
$('#test').click();
|
|
33
|
+
expect($('.dt-datetime th:eq(0)').text()).toBe('Wed');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// For simplicity, this is the only place when jQuery initialisation is tested.
|
|
37
|
+
// Elsewhere the tests will always use the object approach shown above
|
|
38
|
+
dt.html('input');
|
|
39
|
+
it('jQuery initialsiation', function () {
|
|
40
|
+
$('#test').dtDateTime();
|
|
41
|
+
expect($('.dt-datetime').length).toBe(0);
|
|
42
|
+
$('#test').click();
|
|
43
|
+
expect($('.dt-datetime').length).toBe(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
dt.html('input');
|
|
47
|
+
it('jQuery initialsiation with options', function () {
|
|
48
|
+
$('#test').dtDateTime({firstDay: 3});
|
|
49
|
+
$('#test').click();
|
|
50
|
+
expect($('.dt-datetime th:eq(0)').text()).toBe('Wed');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
describe('dateTime - options - maxDate', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
function pad(num) {
|
|
8
|
+
return num < 10 ? '0' + num : num;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getToday() {
|
|
12
|
+
let d = new Date();
|
|
13
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + pad(d.getDate());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getMidMonth() {
|
|
17
|
+
let d = new Date();
|
|
18
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + '15';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('Functional tests', function () {
|
|
22
|
+
let thisYear = new Date().getFullYear().toString();
|
|
23
|
+
|
|
24
|
+
dt.html('input');
|
|
25
|
+
it('Default', function () {
|
|
26
|
+
new DateTime(document.getElementById('test'), {});
|
|
27
|
+
$('#test').click();
|
|
28
|
+
expect($('select.dt-datetime-year option').length).toBe(51);
|
|
29
|
+
expect($('select.dt-datetime-year option:last-child').val()).toBe((new Date().getFullYear() + 25).toString());
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
dt.html('input');
|
|
33
|
+
it('String', function () {
|
|
34
|
+
new DateTime(document.getElementById('test'), {
|
|
35
|
+
maxDate: getToday()
|
|
36
|
+
});
|
|
37
|
+
$('#test').click();
|
|
38
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
39
|
+
expect($('select.dt-datetime-year option:last-child').val()).toBe(thisYear);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
dt.html('input');
|
|
43
|
+
it('String - mid-month', function () {
|
|
44
|
+
new DateTime(document.getElementById('test'), {
|
|
45
|
+
maxDate: getMidMonth()
|
|
46
|
+
});
|
|
47
|
+
$('#test').click();
|
|
48
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
49
|
+
expect($('select.dt-datetime-year option:last-child').val()).toBe(thisYear);
|
|
50
|
+
expect($('tbody tr:eq(1) td:eq(0)').hasClass('disabled')).toBe(false);
|
|
51
|
+
expect($('tbody tr:eq(3) td:eq(0)').hasClass('disabled')).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
dt.html('input');
|
|
55
|
+
it('Date - mid-month', function () {
|
|
56
|
+
new DateTime(document.getElementById('test'), {
|
|
57
|
+
maxDate: new Date(getMidMonth())
|
|
58
|
+
});
|
|
59
|
+
$('#test').click();
|
|
60
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
61
|
+
expect($('select.dt-datetime-year option:last-child').val()).toBe(thisYear);
|
|
62
|
+
expect($('tbody tr:eq(1) td:eq(0)').hasClass('disabled')).toBe(false);
|
|
63
|
+
expect($('tbody tr:eq(3) td:eq(0)').hasClass('disabled')).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
describe('dateTime - options - minDate', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
function pad(num) {
|
|
8
|
+
return num < 10 ? '0' + num : num;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getToday() {
|
|
12
|
+
let d = new Date();
|
|
13
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + pad(d.getDate());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getMidMonth() {
|
|
17
|
+
let d = new Date();
|
|
18
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + '15';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('Functional tests', function () {
|
|
22
|
+
let thisYear = new Date().getFullYear().toString();
|
|
23
|
+
|
|
24
|
+
dt.html('input');
|
|
25
|
+
it('Default', function () {
|
|
26
|
+
new DateTime(document.getElementById('test'), {});
|
|
27
|
+
$('#test').click();
|
|
28
|
+
expect($('select.dt-datetime-year option').length).toBe(51);
|
|
29
|
+
expect($('select.dt-datetime-year option:first-child').val()).toBe((new Date().getFullYear() - 25).toString());
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
dt.html('input');
|
|
33
|
+
it('String', function () {
|
|
34
|
+
new DateTime(document.getElementById('test'), {
|
|
35
|
+
minDate: getToday()
|
|
36
|
+
});
|
|
37
|
+
$('#test').click();
|
|
38
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
39
|
+
expect($('select.dt-datetime-year option:first-child').val()).toBe(thisYear);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
dt.html('input');
|
|
43
|
+
it('String - mid-month', function () {
|
|
44
|
+
new DateTime(document.getElementById('test'), {
|
|
45
|
+
minDate: getMidMonth()
|
|
46
|
+
});
|
|
47
|
+
$('#test').click();
|
|
48
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
49
|
+
expect($('select.dt-datetime-year option:first-child').val()).toBe(thisYear);
|
|
50
|
+
expect($('tbody tr:eq(1) td:eq(0)').hasClass('disabled')).toBe(true);
|
|
51
|
+
expect($('tbody tr:eq(3) td:eq(0)').hasClass('disabled')).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
dt.html('input');
|
|
55
|
+
it('Date - mid-month', function () {
|
|
56
|
+
new DateTime(document.getElementById('test'), {
|
|
57
|
+
minDate: new Date(getMidMonth())
|
|
58
|
+
});
|
|
59
|
+
$('#test').click();
|
|
60
|
+
expect($('select.dt-datetime-year option').length).toBe(26);
|
|
61
|
+
expect($('select.dt-datetime-year option:first-child').val()).toBe(thisYear);
|
|
62
|
+
expect($('tbody tr:eq(1) td:eq(0)').hasClass('disabled')).toBe(true);
|
|
63
|
+
expect($('tbody tr:eq(3) td:eq(0)').hasClass('disabled')).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
describe('dateTime - options - onChange', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
let params;
|
|
8
|
+
let count;
|
|
9
|
+
|
|
10
|
+
function pad(num) {
|
|
11
|
+
return num < 10 ? '0' + num : num;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getToday() {
|
|
15
|
+
let d = new Date();
|
|
16
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + pad(d.getDate());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getMidMonth() {
|
|
20
|
+
let d = new Date();
|
|
21
|
+
return d.getFullYear() + '-' + pad(1 + d.getMonth()) + '-' + '15';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('Check the defaults', function () {
|
|
25
|
+
dt.html('input');
|
|
26
|
+
it('Set stuff up', function () {
|
|
27
|
+
new DateTime(document.getElementById('test'), {
|
|
28
|
+
onChange: function () {
|
|
29
|
+
params = arguments;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(params).toBe(undefined);
|
|
34
|
+
});
|
|
35
|
+
it('Trigger a change and confirm correct number of params', function () {
|
|
36
|
+
$('#test').click();
|
|
37
|
+
$('.now button span').click();
|
|
38
|
+
expect(params.length).toBe(3);
|
|
39
|
+
});
|
|
40
|
+
it('Current value', function () {
|
|
41
|
+
expect(params[0]).toBe(getToday());
|
|
42
|
+
});
|
|
43
|
+
it('Date value', function () {
|
|
44
|
+
expect(params[1] instanceof Date).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it('Input element', function () {
|
|
47
|
+
expect($(params[2]).attr('id')).toBe('test');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('Functional tests', function () {
|
|
52
|
+
dt.html('input');
|
|
53
|
+
it('Setup', function () {
|
|
54
|
+
count = 0;
|
|
55
|
+
new DateTime(document.getElementById('test'), {
|
|
56
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
|
57
|
+
onChange: function () {
|
|
58
|
+
count++;
|
|
59
|
+
params = arguments;
|
|
60
|
+
}
|
|
61
|
+
}).val('2021-01-01 12:12:12');
|
|
62
|
+
|
|
63
|
+
$('#test').click();
|
|
64
|
+
expect(count).toBe(0);
|
|
65
|
+
});
|
|
66
|
+
it('... triggers on date', function () {
|
|
67
|
+
$('#test').click();
|
|
68
|
+
$('.dt-datetime-calendar .selected button span').click();
|
|
69
|
+
expect(count).toBe(1);
|
|
70
|
+
});
|
|
71
|
+
it('... does not trigger again if no change', function () {
|
|
72
|
+
$('#test').click();
|
|
73
|
+
$('.dt-datetime-calendar .selected button span').click();
|
|
74
|
+
expect(count).toBe(1);
|
|
75
|
+
});
|
|
76
|
+
it('... triggers on hours', function () {
|
|
77
|
+
$('#test').click();
|
|
78
|
+
$('.dt-datetime-hours tbody tr:eq(0) td:eq(0) button span').click();
|
|
79
|
+
expect(count).toBe(2);
|
|
80
|
+
});
|
|
81
|
+
it('... triggers on minutes', function () {
|
|
82
|
+
$('#test').click();
|
|
83
|
+
$('.dt-datetime-minutes tbody tr:eq(0) td:eq(0) button span').click();
|
|
84
|
+
expect(count).toBe(3);
|
|
85
|
+
});
|
|
86
|
+
it('... triggers on seconds', function () {
|
|
87
|
+
$('#test').click();
|
|
88
|
+
$('.dt-datetime-seconds tbody tr:eq(0) td:eq(0) button span').click();
|
|
89
|
+
expect(count).toBe(4);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
dt.html('input');
|
|
93
|
+
it('Does not trigger on disabled days', function () {
|
|
94
|
+
count = 0;
|
|
95
|
+
new DateTime(document.getElementById('test'), {
|
|
96
|
+
disableDays: [1, 2],
|
|
97
|
+
onChange: function () {
|
|
98
|
+
count++;
|
|
99
|
+
params = arguments;
|
|
100
|
+
}
|
|
101
|
+
}).val('2021-02-05');
|
|
102
|
+
$('#test').click();
|
|
103
|
+
$('.dt-datetime-calendar tbody tr:eq(1) td:eq(1) button span').click();
|
|
104
|
+
expect(count).toBe(0);
|
|
105
|
+
});
|
|
106
|
+
it('... but does on enabled days', function () {
|
|
107
|
+
$('.dt-datetime-calendar tbody tr:eq(1) td:eq(3) button span').click();
|
|
108
|
+
expect(count).toBe(1);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
dt.html('input');
|
|
112
|
+
it('Does not trigger when maxDate set', function () {
|
|
113
|
+
count = 0;
|
|
114
|
+
new DateTime(document.getElementById('test'), {
|
|
115
|
+
maxDate: getMidMonth(),
|
|
116
|
+
onChange: function () {
|
|
117
|
+
count++;
|
|
118
|
+
params = arguments;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
$('#test').click();
|
|
122
|
+
$('.dt-datetime-calendar tbody tr:eq(3) td:eq(0) button span').click();
|
|
123
|
+
expect(count).toBe(0);
|
|
124
|
+
});
|
|
125
|
+
it('... but does on enabled days', function () {
|
|
126
|
+
$('.dt-datetime-calendar tbody tr:eq(1) td:eq(0) button span').click();
|
|
127
|
+
expect(count).toBe(1);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
describe('dateTime - options - showWeekNumber', function () {
|
|
2
|
+
dt.libs({
|
|
3
|
+
js: ['jquery', 'datatables', 'moment', 'datetime'],
|
|
4
|
+
css: ['datatables', 'datetime']
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('Functional tests', function () {
|
|
8
|
+
dt.html('input');
|
|
9
|
+
it('Default: no week number', function () {
|
|
10
|
+
let el = new DateTime(document.getElementById('test'));
|
|
11
|
+
|
|
12
|
+
$('#test').click();
|
|
13
|
+
|
|
14
|
+
el.val('2017-06-15');
|
|
15
|
+
|
|
16
|
+
expect($('td.dt-datetime-week').length).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
dt.html('input');
|
|
20
|
+
it('Show week number', function () {
|
|
21
|
+
let el = new DateTime(document.getElementById('test'), {
|
|
22
|
+
showWeekNumber: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
$('#test').click();
|
|
26
|
+
|
|
27
|
+
el.val('2017-06-15');
|
|
28
|
+
|
|
29
|
+
expect($('td.dt-datetime-week').length).toBe(5);
|
|
30
|
+
});
|
|
31
|
+
it('... correct week number', function () {
|
|
32
|
+
expect($('td.dt-datetime-week:eq(0)').text()).toBe('22');
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|