summaryrefslogtreecommitdiff
path: root/js_tests/admin
diff options
context:
space:
mode:
Diffstat (limited to 'js_tests/admin')
-rw-r--r--js_tests/admin/DateTimeShortcuts.test.js16
-rw-r--r--js_tests/admin/SelectBox.test.js4
-rw-r--r--js_tests/admin/SelectFilter2.test.js2
-rw-r--r--js_tests/admin/actions.test.js4
-rw-r--r--js_tests/admin/core.test.js25
-rw-r--r--js_tests/admin/inlines.test.js54
-rw-r--r--js_tests/admin/jsi18n-mocks.test.js4
7 files changed, 54 insertions, 55 deletions
diff --git a/js_tests/admin/DateTimeShortcuts.test.js b/js_tests/admin/DateTimeShortcuts.test.js
index dfd5f231af..382673602b 100644
--- a/js_tests/admin/DateTimeShortcuts.test.js
+++ b/js_tests/admin/DateTimeShortcuts.test.js
@@ -5,14 +5,14 @@
QUnit.module('admin.DateTimeShortcuts');
QUnit.test('init', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
- var dateField = $('<input type="text" class="vDateField" value="2015-03-16"><br>');
+ const dateField = $('<input type="text" class="vDateField" value="2015-03-16"><br>');
$('#qunit-fixture').append(dateField);
DateTimeShortcuts.init();
- var shortcuts = $('.datetimeshortcuts');
+ const 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);
@@ -23,8 +23,8 @@ QUnit.test('init', function(assert) {
});
QUnit.test('custom time shortcuts', function(assert) {
- var $ = django.jQuery;
- var timeField = $('<input type="text" name="time_test" class="vTimeField">');
+ const $ = django.jQuery;
+ const timeField = $('<input type="text" name="time_test" class="vTimeField">');
$('#qunit-fixture').append(timeField);
DateTimeShortcuts.clockHours.time_test = [['3 a.m.', 3]];
DateTimeShortcuts.init();
@@ -32,9 +32,9 @@ QUnit.test('custom time shortcuts', function(assert) {
});
QUnit.test('time zone offset warning', function(assert) {
- var $ = django.jQuery;
- var savedOffset = $('body').attr('data-admin-utc-offset');
- var timeField = $('<input type="text" name="time_test" class="vTimeField">');
+ const $ = django.jQuery;
+ const savedOffset = $('body').attr('data-admin-utc-offset');
+ const timeField = $('<input type="text" name="time_test" class="vTimeField">');
$('#qunit-fixture').append(timeField);
$('body').attr('data-admin-utc-offset', new Date().getTimezoneOffset() * -60 + 3600);
DateTimeShortcuts.init();
diff --git a/js_tests/admin/SelectBox.test.js b/js_tests/admin/SelectBox.test.js
index bca4941fa6..4f3a27c149 100644
--- a/js_tests/admin/SelectBox.test.js
+++ b/js_tests/admin/SelectBox.test.js
@@ -5,14 +5,14 @@
QUnit.module('admin.SelectBox');
QUnit.test('init: no options', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('<select id="id"></select>').appendTo('#qunit-fixture');
SelectBox.init('id');
assert.equal(SelectBox.cache.id.length, 0);
});
QUnit.test('filter', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('<select id="id"></select>').appendTo('#qunit-fixture');
$('<option value="0">A</option>').appendTo('#id');
$('<option value="1">B</option>').appendTo('#id');
diff --git a/js_tests/admin/SelectFilter2.test.js b/js_tests/admin/SelectFilter2.test.js
index fd0f309a04..3f85e70fe9 100644
--- a/js_tests/admin/SelectFilter2.test.js
+++ b/js_tests/admin/SelectFilter2.test.js
@@ -5,7 +5,7 @@
QUnit.module('admin.SelectFilter2');
QUnit.test('init', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('<form><select id="id"></select></form>').appendTo('#qunit-fixture');
$('<option value="0">A</option>').appendTo('#id');
SelectFilter.init('id', 'things', 0);
diff --git a/js_tests/admin/actions.test.js b/js_tests/admin/actions.test.js
index 8d15dbd55e..10c9578dff 100644
--- a/js_tests/admin/actions.test.js
+++ b/js_tests/admin/actions.test.js
@@ -9,7 +9,7 @@ QUnit.module('admin.actions', {
window._actions_icnt = '100';
/* eslint-enable */
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('#qunit-fixture').append($('#result-table').text());
$('tr input.action-select').actions();
@@ -17,7 +17,7 @@ QUnit.module('admin.actions', {
});
QUnit.test('check', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
assert.notOk($('.action-select').is(':checked'));
$('#action-toggle').click();
assert.ok($('.action-select').is(':checked'));
diff --git a/js_tests/admin/core.test.js b/js_tests/admin/core.test.js
index ad5b91a903..dea638b779 100644
--- a/js_tests/admin/core.test.js
+++ b/js_tests/admin/core.test.js
@@ -42,7 +42,7 @@ QUnit.test('Date.getTwoDigitSecond', function(assert) {
});
QUnit.test('Date.strftime', function(assert) {
- var date = new Date(2014, 6, 1, 11, 0, 5);
+ const date = new Date(2014, 6, 1, 11, 0, 5);
assert.equal(date.strftime('%Y-%m-%d %H:%M:%S'), '2014-07-01 11:00:05');
assert.equal(date.strftime('%B %d, %Y'), 'July 01, 2014');
});
@@ -50,26 +50,26 @@ QUnit.test('Date.strftime', function(assert) {
QUnit.test('String.strptime', function(assert) {
// Use UTC functions for extracting dates since the calendar uses them as
// well. Month numbering starts with 0 (January).
- var firstParsedDate = '1988-02-26'.strptime('%Y-%m-%d');
+ const firstParsedDate = '1988-02-26'.strptime('%Y-%m-%d');
assert.equal(firstParsedDate.getUTCDate(), 26);
assert.equal(firstParsedDate.getUTCMonth(), 1);
assert.equal(firstParsedDate.getUTCFullYear(), 1988);
// A %y value in the range of [69, 99] is in the previous century.
- var secondParsedDate = '26/02/88'.strptime('%d/%m/%y');
+ const secondParsedDate = '26/02/88'.strptime('%d/%m/%y');
assert.equal(secondParsedDate.getUTCDate(), 26);
assert.equal(secondParsedDate.getUTCMonth(), 1);
assert.equal(secondParsedDate.getUTCFullYear(), 1988);
- var format = django.get_format('DATE_INPUT_FORMATS')[0];
- var thirdParsedDate = '1983-11-20'.strptime(format);
+ const format = django.get_format('DATE_INPUT_FORMATS')[0];
+ const thirdParsedDate = '1983-11-20'.strptime(format);
assert.equal(thirdParsedDate.getUTCDate(), 20);
assert.equal(thirdParsedDate.getUTCMonth(), 10);
assert.equal(thirdParsedDate.getUTCFullYear(), 1983);
// A %y value in the range of [00, 68] is in the current century.
- var fourthParsedDate = '27/09/68'.strptime('%d/%m/%y');
+ const fourthParsedDate = '27/09/68'.strptime('%d/%m/%y');
assert.equal(fourthParsedDate.getUTCDate(), 27);
assert.equal(fourthParsedDate.getUTCMonth(), 8);
assert.equal(fourthParsedDate.getUTCFullYear(), 2068);
@@ -80,10 +80,9 @@ QUnit.test('String.strptime', function(assert) {
// Feb 26, 1988 00:00:00 EEST is Feb 25, 21:00:00 UTC.
// Checking timezones from GMT+0100 to GMT+1200
- var i, tz, date;
- for (i = 1; i <= 12; i++) {
- tz = i > 9 ? '' + i : '0' + i;
- date = new Date(Date.parse('Feb 26, 1988 00:00:00 GMT+' + tz + '00'));
+ for (let i = 1; i <= 12; i++) {
+ const tz = i > 9 ? '' + i : '0' + i;
+ const date = new Date(Date.parse('Feb 26, 1988 00:00:00 GMT+' + tz + '00'));
assert.notEqual(date.getUTCDate(), 26);
assert.equal(date.getUTCDate(), 25);
assert.equal(date.getUTCMonth(), 1);
@@ -91,9 +90,9 @@ QUnit.test('String.strptime', function(assert) {
}
// Checking timezones from GMT+0000 to GMT-1100
- for (i = 0; i <= 11; i++) {
- tz = i > 9 ? '' + i : '0' + i;
- date = new Date(Date.parse('Feb 26, 1988 00:00:00 GMT-' + tz + '00'));
+ for (let i = 0; i <= 11; i++) {
+ const tz = i > 9 ? '' + i : '0' + i;
+ const date = new Date(Date.parse('Feb 26, 1988 00:00:00 GMT-' + tz + '00'));
assert.equal(date.getUTCDate(), 26);
assert.equal(date.getUTCMonth(), 1);
assert.equal(date.getUTCFullYear(), 1988);
diff --git a/js_tests/admin/inlines.test.js b/js_tests/admin/inlines.test.js
index 62a4281190..7c8493742b 100644
--- a/js_tests/admin/inlines.test.js
+++ b/js_tests/admin/inlines.test.js
@@ -4,8 +4,8 @@
QUnit.module('admin.inlines: tabular formsets', {
beforeEach: function() {
- var $ = django.jQuery;
- var that = this;
+ const $ = django.jQuery;
+ const that = this;
this.addText = 'Add another';
$('#qunit-fixture').append($('#tabular-formset').text());
@@ -25,14 +25,14 @@ QUnit.test('no forms', function(assert) {
});
QUnit.test('add form', function(assert) {
- var addButton = this.table.find('.add-row a');
+ const addButton = this.table.find('.add-row a');
assert.equal(addButton.text(), this.addText);
addButton.click();
assert.ok(this.table.find('#first-1'));
});
QUnit.test('added form has remove button', function(assert) {
- var addButton = this.table.find('.add-row a');
+ const addButton = this.table.find('.add-row a');
assert.equal(addButton.text(), this.addText);
addButton.click();
assert.equal(this.table.find('#first-1 .inline-deletelink').length, 1);
@@ -40,9 +40,9 @@ QUnit.test('added form has remove button', function(assert) {
QUnit.test('add/remove form events', function(assert) {
assert.expect(6);
- var $ = django.jQuery;
- var $document = $(document);
- var addButton = this.table.find('.add-row a');
+ const $ = django.jQuery;
+ const $document = $(document);
+ const addButton = this.table.find('.add-row a');
$document.on('formset:added', function(event, $row, formsetName) {
assert.ok(true, 'event `formset:added` triggered');
assert.equal(true, $row.is('#first-1'));
@@ -50,8 +50,8 @@ QUnit.test('add/remove form events', function(assert) {
$document.off('formset:added');
});
addButton.click();
- var deletedRow = $('#first-1');
- var deleteLink = this.table.find('.inline-deletelink');
+ const deletedRow = $('#first-1');
+ const deleteLink = this.table.find('.inline-deletelink');
$document.on('formset:removed', function(event, $row, formsetName) {
assert.ok(true, 'event `formset:removed` triggered');
assert.equal(true, $row.is(deletedRow));
@@ -62,13 +62,13 @@ QUnit.test('add/remove form events', function(assert) {
});
QUnit.test('existing add button', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('#qunit-fixture').empty(); // Clear the table added in beforeEach
$('#qunit-fixture').append($('#tabular-formset').text());
this.table = $('table.inline');
this.inlineRow = this.table.find('tr');
this.table.append('<i class="add-button"></i>');
- var addButton = this.table.find('.add-button');
+ const addButton = this.table.find('.add-button');
this.inlineRow.tabularFormset('table.inline tr', {
prefix: 'first',
deleteText: 'Remove',
@@ -82,7 +82,7 @@ QUnit.test('existing add button', function(assert) {
QUnit.module('admin.inlines: tabular formsets with validation errors', {
beforeEach: function() {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('#qunit-fixture').append($('#tabular-formset-with-validation-error').text());
this.table = $('table.inline');
@@ -94,7 +94,7 @@ QUnit.module('admin.inlines: tabular formsets with validation errors', {
});
QUnit.test('first form has delete checkbox and no button', function(assert) {
- var tr = this.inlineRows.slice(0, 1);
+ const tr = this.inlineRows.slice(0, 1);
assert.ok(tr.hasClass('dynamic-second'));
assert.ok(tr.hasClass('has_original'));
assert.equal(tr.find('td.delete input').length, 1);
@@ -102,14 +102,14 @@ QUnit.test('first form has delete checkbox and no button', function(assert) {
});
QUnit.test('dynamic form has remove button', function(assert) {
- var tr = this.inlineRows.slice(1, 2);
+ const tr = this.inlineRows.slice(1, 2);
assert.ok(tr.hasClass('dynamic-second'));
assert.notOk(tr.hasClass('has_original'));
assert.equal(tr.find('.inline-deletelink').length, 1);
});
QUnit.test('dynamic template has nothing', function(assert) {
- var tr = this.inlineRows.slice(2, 3);
+ const tr = this.inlineRows.slice(2, 3);
assert.ok(tr.hasClass('empty-form'));
assert.notOk(tr.hasClass('dynamic-second'));
assert.notOk(tr.hasClass('has_original'));
@@ -117,19 +117,19 @@ QUnit.test('dynamic template has nothing', function(assert) {
});
QUnit.test('removing a form-row also removed related row with non-field errors', function(assert) {
- var $ = django.jQuery;
+ const $ = django.jQuery;
assert.ok(this.table.find('.row-form-errors').length);
- var tr = this.inlineRows.slice(1, 2);
- var trWithErrors = tr.prev();
+ const tr = this.inlineRows.slice(1, 2);
+ const trWithErrors = tr.prev();
assert.ok(trWithErrors.hasClass('row-form-errors'));
- var deleteLink = tr.find('a.inline-deletelink');
+ const deleteLink = tr.find('a.inline-deletelink');
deleteLink.trigger($.Event('click', {target: deleteLink}));
assert.notOk(this.table.find('.row-form-errors').length);
});
QUnit.module('admin.inlines: tabular formsets with max_num', {
beforeEach: function() {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('#qunit-fixture').append($('#tabular-formset-with-validation-error').text());
this.table = $('table.inline');
this.maxNum = $('input.id_second-MAX_NUM_FORMS');
@@ -142,14 +142,14 @@ QUnit.module('admin.inlines: tabular formsets with max_num', {
});
QUnit.test('does not show the add button if already at max_num', function(assert) {
- var addButton = this.table.find('tr.add_row > td > a');
+ const addButton = this.table.find('tr.add_row > td > a');
assert.notOk(addButton.is(':visible'));
});
QUnit.test('make addButton visible again', function(assert) {
- var $ = django.jQuery;
- var addButton = this.table.find('tr.add_row > td > a');
- var removeButton = this.table.find('tr.form-row:first').find('a.inline-deletelink');
+ const $ = django.jQuery;
+ const addButton = this.table.find('tr.add_row > td > a');
+ const removeButton = this.table.find('tr.form-row:first').find('a.inline-deletelink');
removeButton.trigger($.Event( "click", { target: removeButton } ));
assert.notOk(addButton.is(':visible'));
});
@@ -157,7 +157,7 @@ QUnit.test('make addButton visible again', function(assert) {
QUnit.module('admin.inlines: tabular formsets with min_num', {
beforeEach: function() {
- var $ = django.jQuery;
+ const $ = django.jQuery;
$('#qunit-fixture').append($('#tabular-formset-with-validation-error').text());
this.table = $('table.inline');
this.minNum = $('input#id_second-MIN_NUM_FORMS');
@@ -174,8 +174,8 @@ QUnit.test('does not show the remove buttons if already at min_num', function(as
});
QUnit.test('make removeButtons visible again', function(assert) {
- var $ = django.jQuery;
- var addButton = this.table.find('tr.add-row > td > a');
+ const $ = django.jQuery;
+ const addButton = this.table.find('tr.add-row > td > a');
addButton.trigger($.Event( "click", { target: addButton } ));
assert.equal(this.table.find('.inline-deletelink:visible').length, 2);
});
diff --git a/js_tests/admin/jsi18n-mocks.test.js b/js_tests/admin/jsi18n-mocks.test.js
index f04b0576f6..13d5b0e33c 100644
--- a/js_tests/admin/jsi18n-mocks.test.js
+++ b/js_tests/admin/jsi18n-mocks.test.js
@@ -1,6 +1,6 @@
(function(globals) {
'use strict';
- var django = globals.django || (globals.django = {});
+ const django = globals.django;
django.pluralidx = function(count) { return (count === 1) ? 0 : 1; };
@@ -69,7 +69,7 @@
};
django.get_format = function(format_type) {
- var value = django.formats[format_type];
+ const value = django.formats[format_type];
if (typeof value === 'undefined') {
return format_type;
} else {