mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Updated to QUnit 2.0.1.
This commit is contained in:
parent
a85e84212e
commit
620dcdde6e
11 changed files with 709 additions and 496 deletions
|
@ -1,10 +1,10 @@
|
|||
/* global module, test, DateTimeShortcuts */
|
||||
/* global QUnit, DateTimeShortcuts */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.DateTimeShortcuts');
|
||||
QUnit.module('admin.DateTimeShortcuts');
|
||||
|
||||
test('init', function(assert) {
|
||||
QUnit.test('init', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
|
||||
var dateField = $('<input type="text" class="vDateField" value="2015-03-16"><br>');
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/* global module, test, id_to_windowname,
|
||||
/* global QUnit, id_to_windowname,
|
||||
windowname_to_id */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.RelatedObjectLookups');
|
||||
QUnit.module('admin.RelatedObjectLookups');
|
||||
|
||||
test('id_to_windowname', function(assert) {
|
||||
QUnit.test('id_to_windowname', function(assert) {
|
||||
assert.equal(id_to_windowname('.test'), '__dot__test');
|
||||
assert.equal(id_to_windowname('misc-test'), 'misc__dash__test');
|
||||
});
|
||||
|
||||
test('windowname_to_id', function(assert) {
|
||||
QUnit.test('windowname_to_id', function(assert) {
|
||||
assert.equal(windowname_to_id('__dot__test'), '.test');
|
||||
assert.equal(windowname_to_id('misc__dash__test'), 'misc-test');
|
||||
});
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/* global module, test, SelectBox */
|
||||
/* global QUnit, SelectBox */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.SelectBox');
|
||||
QUnit.module('admin.SelectBox');
|
||||
|
||||
test('init: no options', function(assert) {
|
||||
QUnit.test('init: no options', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
$('<select id="id"></select>').appendTo('#qunit-fixture');
|
||||
SelectBox.init('id');
|
||||
assert.equal(SelectBox.cache.id.length, 0);
|
||||
});
|
||||
|
||||
test('filter', function(assert) {
|
||||
QUnit.test('filter', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
$('<select id="id"></select>').appendTo('#qunit-fixture');
|
||||
$('<option value="0">A</option>').appendTo('#id');
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* global module, test, SelectFilter */
|
||||
/* global QUnit, SelectFilter */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.SelectFilter2');
|
||||
QUnit.module('admin.SelectFilter2');
|
||||
|
||||
test('init', function(assert) {
|
||||
QUnit.test('init', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
$('<form><select id="id"></select></form>').appendTo('#qunit-fixture');
|
||||
$('<option value="0">A</option>').appendTo('#id');
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* global module, test */
|
||||
/* global QUnit */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.actions', {
|
||||
QUnit.module('admin.actions', {
|
||||
beforeEach: function() {
|
||||
// Number of results shown on page
|
||||
/* eslint-disable */
|
||||
|
@ -16,7 +16,7 @@ module('admin.actions', {
|
|||
}
|
||||
});
|
||||
|
||||
test('check', function(assert) {
|
||||
QUnit.test('check', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
assert.notOk($('.action-select').is(':checked'));
|
||||
$('#action-toggle').click();
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
/* global module, test */
|
||||
/* global QUnit */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.core');
|
||||
QUnit.module('admin.core');
|
||||
|
||||
test('Date.getTwelveHours', function(assert) {
|
||||
QUnit.test('Date.getTwelveHours', function(assert) {
|
||||
assert.equal(new Date(2011, 0, 1, 0, 0).getTwelveHours(), 12, '0:00');
|
||||
assert.equal(new Date(2011, 0, 1, 11, 0).getTwelveHours(), 11, '11:00');
|
||||
assert.equal(new Date(2011, 0, 1, 16, 0).getTwelveHours(), 4, '16:00');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitMonth', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitMonth', function(assert) {
|
||||
assert.equal(new Date(2011, 0, 1).getTwoDigitMonth(), '01', 'jan 1');
|
||||
assert.equal(new Date(2011, 9, 1).getTwoDigitMonth(), '10', 'oct 1');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitDate', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitDate', function(assert) {
|
||||
assert.equal(new Date(2011, 0, 1).getTwoDigitDate(), '01', 'jan 1');
|
||||
assert.equal(new Date(2011, 0, 15).getTwoDigitDate(), '15', 'jan 15');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitTwelveHour', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitTwelveHour', function(assert) {
|
||||
assert.equal(new Date(2011, 0, 1, 0, 0).getTwoDigitTwelveHour(), '12', '0:00');
|
||||
assert.equal(new Date(2011, 0, 1, 4, 0).getTwoDigitTwelveHour(), '04', '4:00');
|
||||
assert.equal(new Date(2011, 0, 1, 22, 0).getTwoDigitTwelveHour(), '10', '22:00');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitHour', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitHour', function(assert) {
|
||||
assert.equal(new Date(2014, 6, 1, 9, 0).getTwoDigitHour(), '09', '9:00 am is 09');
|
||||
assert.equal(new Date(2014, 6, 1, 11, 0).getTwoDigitHour(), '11', '11:00 am is 11');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitMinute', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitMinute', function(assert) {
|
||||
assert.equal(new Date(2014, 6, 1, 0, 5).getTwoDigitMinute(), '05', '12:05 am is 05');
|
||||
assert.equal(new Date(2014, 6, 1, 0, 15).getTwoDigitMinute(), '15', '12:15 am is 15');
|
||||
});
|
||||
|
||||
test('Date.getTwoDigitSecond', function(assert) {
|
||||
QUnit.test('Date.getTwoDigitSecond', function(assert) {
|
||||
assert.equal(new Date(2014, 6, 1, 0, 0, 2).getTwoDigitSecond(), '02', '12:00:02 am is 02');
|
||||
assert.equal(new Date(2014, 6, 1, 0, 0, 20).getTwoDigitSecond(), '20', '12:00:20 am is 20');
|
||||
});
|
||||
|
||||
test('Date.getHourMinute', function(assert) {
|
||||
QUnit.test('Date.getHourMinute', function(assert) {
|
||||
assert.equal(new Date(2014, 6, 1, 11, 0).getHourMinute(), '11:00', '11:00 am is 11:00');
|
||||
assert.equal(new Date(2014, 6, 1, 13, 25).getHourMinute(), '13:25', '1:25 pm is 13:25');
|
||||
});
|
||||
|
||||
test('Date.getHourMinuteSecond', function(assert) {
|
||||
QUnit.test('Date.getHourMinuteSecond', function(assert) {
|
||||
assert.equal(new Date(2014, 6, 1, 11, 0, 0).getHourMinuteSecond(), '11:00:00', '11:00 am is 11:00:00');
|
||||
assert.equal(new Date(2014, 6, 1, 17, 45, 30).getHourMinuteSecond(), '17:45:30', '5:45:30 pm is 17:45:30');
|
||||
});
|
||||
|
||||
test('Date.strftime', function(assert) {
|
||||
QUnit.test('Date.strftime', function(assert) {
|
||||
var 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');
|
||||
});
|
||||
|
||||
test('String.strptime', 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');
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* global module, test */
|
||||
/* global QUnit */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.inlines: tabular formsets', {
|
||||
QUnit.module('admin.inlines: tabular formsets', {
|
||||
beforeEach: function() {
|
||||
var $ = django.jQuery;
|
||||
var that = this;
|
||||
|
@ -19,19 +19,19 @@ module('admin.inlines: tabular formsets', {
|
|||
}
|
||||
});
|
||||
|
||||
test('no forms', function(assert) {
|
||||
QUnit.test('no forms', function(assert) {
|
||||
assert.ok(this.inlineRow.hasClass('dynamic-first'));
|
||||
assert.equal(this.table.find('.add-row a').text(), this.addText);
|
||||
});
|
||||
|
||||
test('add form', function(assert) {
|
||||
QUnit.test('add form', function(assert) {
|
||||
var addButton = this.table.find('.add-row a');
|
||||
assert.equal(addButton.text(), this.addText);
|
||||
addButton.click();
|
||||
assert.ok(this.table.find('#first-1').hasClass('row2'));
|
||||
});
|
||||
|
||||
test('add/remove form events', function(assert) {
|
||||
QUnit.test('add/remove form events', function(assert) {
|
||||
assert.expect(6);
|
||||
var $ = django.jQuery;
|
||||
var $document = $(document);
|
||||
|
@ -52,7 +52,7 @@ test('add/remove form events', function(assert) {
|
|||
deleteLink.click();
|
||||
});
|
||||
|
||||
test('existing add button', function(assert) {
|
||||
QUnit.test('existing add button', function(assert) {
|
||||
var $ = django.jQuery;
|
||||
$('#qunit-fixture').empty(); // Clear the table added in beforeEach
|
||||
$('#qunit-fixture').append($('#tabular-formset').text());
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* global module, test, parseTimeString */
|
||||
/* global QUnit, parseTimeString */
|
||||
/* eslint global-strict: 0, strict: 0 */
|
||||
'use strict';
|
||||
|
||||
module('admin.timeparse');
|
||||
QUnit.module('admin.timeparse');
|
||||
|
||||
test('parseTimeString', function(assert) {
|
||||
QUnit.test('parseTimeString', function(assert) {
|
||||
function time(then, expected) {
|
||||
assert.equal(parseTimeString(then), expected);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue