SelectBox.test.js 765 B

123456789101112131415161718192021222324
  1. /* global QUnit, SelectBox */
  2. /* eslint strict: 0 */
  3. 'use strict';
  4. QUnit.module('admin.SelectBox');
  5. QUnit.test('init: no options', function(assert) {
  6. const $ = django.jQuery;
  7. $('<select id="id"></select>').appendTo('#qunit-fixture');
  8. SelectBox.init('id');
  9. assert.equal(SelectBox.cache.id.length, 0);
  10. });
  11. QUnit.test('filter', function(assert) {
  12. const $ = django.jQuery;
  13. $('<select id="id"></select>').appendTo('#qunit-fixture');
  14. $('<option value="0">A</option>').appendTo('#id');
  15. $('<option value="1">B</option>').appendTo('#id');
  16. SelectBox.init('id');
  17. assert.equal($('#id option').length, 2);
  18. SelectBox.filter('id', "A");
  19. assert.equal($('#id option').length, 1);
  20. assert.equal($('#id option').text(), "A");
  21. });