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:
20
js_tests/admin/SelectBox.test.js
Normal file
20
js_tests/admin/SelectBox.test.js
Normal 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");
|
||||
});
|
||||
Reference in New Issue
Block a user