fradrive/frontend/src/utils/check-all/check-all.spec.js
2022-10-12 09:35:16 +02:00

39 lines
969 B
JavaScript

// SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import { CheckAll, CHECK_ALL_INITIALIZED_CLASS } from './check-all';
const MOCK_APP = {
utilRegistry: {
initAll: () => {},
},
};
describe('CheckAll', () => {
let checkAll;
beforeEach(() => {
const element = document.createElement('table');
checkAll = new CheckAll(element, MOCK_APP);
});
it('should create', () => {
expect(checkAll).toBeTruthy();
});
it('should throw if called without an element', () => {
expect(() => {
new CheckAll();
}).toThrow();
});
it('should destroy CheckAll', () => {
checkAll.destroy();
expect(checkAll._eventManager._registeredListeners.length).toBe(0);
expect(checkAll._element.classList).not.toEqual(jasmine.arrayContaining([CHECK_ALL_INITIALIZED_CLASS]));
});
});