1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

DEP 0003 -- Added JavaScript unit tests.

Setup QUnit, added tests, and measured test coverage.

Thanks to Nick Sanford for the initial tests.
This commit is contained in:
Trey Hunner
2015-04-14 10:55:57 -04:00
committed by Tim Graham
parent 3bbaf84d65
commit 2d0dead224
19 changed files with 4716 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
module('admin.SelectBox');
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) {
var $ = django.jQuery;
$('<select id="id"></select>').appendTo('#qunit-fixture');
$('<option value="0">A</option>').appendTo('#id');
$('<option value="1">B</option>').appendTo('#id');
SelectBox.init('id');
assert.equal($('#id option').length, 2);
SelectBox.filter('id', "A");
assert.equal($('#id option').length, 1);
assert.equal($('#id option').text(), "A");
});