1
0
mirror of https://github.com/django/django.git synced 2025-03-24 00:00:45 +00:00

Fixed #28929 -- Corrected QUnit examples.

This commit is contained in:
weijunji 2017-12-19 03:49:00 +08:00 committed by Tim Graham
parent 4dcd7723d5
commit 1ef8b30abe

View File

@ -81,27 +81,27 @@ Django's JavaScript tests use `QUnit`_. Here is an example test module:
.. code-block:: javascript
module('magicTricks', {
QUnit.module('magicTricks', {
beforeEach: function() {
var $ = django.jQuery;
$('#qunit-fixture').append('<button class="button"></button>');
}
});
test('removeOnClick removes button on click', function(assert) {
QUnit.test('removeOnClick removes button on click', function(assert) {
var $ = django.jQuery;
removeOnClick('.button');
assert.equal($('.button').length === 1);
assert.equal($('.button').length, 1);
$('.button').click();
assert.equal($('.button').length === 0);
assert.equal($('.button').length, 0);
});
test('copyOnClick adds button on click', function(assert) {
QUnit.test('copyOnClick adds button on click', function(assert) {
var $ = django.jQuery;
copyOnClick('.button');
assert.equal($('.button').length === 1);
assert.equal($('.button').length, 1);
$('.button').click();
assert.equal($('.button').length === 2);
assert.equal($('.button').length, 2);
});