2016-12-20 01:43:47 +08:00
|
|
|
/* global QUnit, DateTimeShortcuts */
|
2015-08-26 12:24:55 +08:00
|
|
|
/* eslint global-strict: 0, strict: 0 */
|
|
|
|
'use strict';
|
|
|
|
|
2016-12-20 01:43:47 +08:00
|
|
|
QUnit.module('admin.DateTimeShortcuts');
|
2015-04-14 22:55:57 +08:00
|
|
|
|
2016-12-20 01:43:47 +08:00
|
|
|
QUnit.test('init', function(assert) {
|
2015-04-14 22:55:57 +08:00
|
|
|
var $ = django.jQuery;
|
|
|
|
|
|
|
|
var dateField = $('<input type="text" class="vDateField" value="2015-03-16"><br>');
|
|
|
|
$('#qunit-fixture').append(dateField);
|
|
|
|
|
|
|
|
DateTimeShortcuts.init();
|
|
|
|
|
|
|
|
var shortcuts = $('.datetimeshortcuts');
|
|
|
|
assert.equal(shortcuts.length, 1);
|
|
|
|
assert.equal(shortcuts.find('a:first').text(), 'Today');
|
|
|
|
assert.equal(shortcuts.find('a:last .date-icon').length, 1);
|
2015-12-16 22:11:00 +08:00
|
|
|
|
|
|
|
// To prevent incorrect timezone warnings on date/time widgets, timezoneOffset
|
|
|
|
// should be 0 when a timezone offset isn't set in the HTML body attribute.
|
|
|
|
assert.equal(DateTimeShortcuts.timezoneOffset, 0);
|
2015-04-14 22:55:57 +08:00
|
|
|
});
|
2017-01-06 06:21:40 +08:00
|
|
|
|
|
|
|
QUnit.test('custom time shortcuts', function(assert) {
|
|
|
|
var $ = django.jQuery;
|
|
|
|
var timeField = $('<input type="text" name="time_test" class="vTimeField">');
|
|
|
|
$('#qunit-fixture').append(timeField);
|
|
|
|
DateTimeShortcuts.clockHours.time_test = [['3 a.m.', 3]];
|
|
|
|
DateTimeShortcuts.init();
|
|
|
|
assert.equal($('.clockbox').find('a').first().text(), '3 a.m.');
|
|
|
|
});
|