mirror of https://github.com/django/django.git
[2.0.x] Fixed #28929 -- Corrected QUnit examples.
Backport of 1ef8b30abe
from master
This commit is contained in:
parent
cc17f39c9c
commit
f0801119b7
|
@ -81,27 +81,27 @@ Django's JavaScript tests use `QUnit`_. Here is an example test module:
|
||||||
|
|
||||||
.. code-block:: javascript
|
.. code-block:: javascript
|
||||||
|
|
||||||
module('magicTricks', {
|
QUnit.module('magicTricks', {
|
||||||
beforeEach: function() {
|
beforeEach: function() {
|
||||||
var $ = django.jQuery;
|
var $ = django.jQuery;
|
||||||
$('#qunit-fixture').append('<button class="button"></button>');
|
$('#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;
|
var $ = django.jQuery;
|
||||||
removeOnClick('.button');
|
removeOnClick('.button');
|
||||||
assert.equal($('.button').length === 1);
|
assert.equal($('.button').length, 1);
|
||||||
$('.button').click();
|
$('.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;
|
var $ = django.jQuery;
|
||||||
copyOnClick('.button');
|
copyOnClick('.button');
|
||||||
assert.equal($('.button').length === 1);
|
assert.equal($('.button').length, 1);
|
||||||
$('.button').click();
|
$('.button').click();
|
||||||
assert.equal($('.button').length === 2);
|
assert.equal($('.button').length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue