2024-05-05 21:03:16 +02:00
|
|
|
/* global QUnit, initSidebarQuickFilter */
|
2020-12-04 12:50:11 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
QUnit.module('admin.sidebar: filter', {
|
|
|
|
beforeEach: function() {
|
|
|
|
const $ = django.jQuery;
|
|
|
|
$('#qunit-fixture').append($('#nav-sidebar-filter').text());
|
|
|
|
this.navSidebar = $('#nav-sidebar');
|
|
|
|
this.navFilter = $('#nav-filter');
|
|
|
|
initSidebarQuickFilter();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test('filter by a model name', function(assert) {
|
|
|
|
assert.equal(this.navSidebar.find('th[scope=row] a').length, 2);
|
|
|
|
|
|
|
|
this.navFilter.val('us'); // Matches 'users'.
|
|
|
|
this.navFilter[0].dispatchEvent(new Event('change'));
|
|
|
|
assert.equal(this.navSidebar.find('tr[class^="model-"]:visible').length, 1);
|
|
|
|
|
|
|
|
this.navFilter.val('nonexistent');
|
|
|
|
this.navFilter[0].dispatchEvent(new Event('change'));
|
|
|
|
assert.equal(this.navSidebar.find('tr[class^="model-"]:visible').length, 0);
|
|
|
|
});
|