This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
fradrive-old/frontend/src/utils/async-form/async-form.spec.js
2022-10-12 09:35:16 +02:00

32 lines
837 B
JavaScript

// SPDX-FileCopyrightText: 2022 Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import { AsyncForm, ASYNC_FORM_INITIALIZED_CLASS } from './async-form';
describe('AsyncForm', () => {
let asyncForm;
beforeEach(() => {
const element = document.createElement('div');
asyncForm = new AsyncForm(element);
});
it('should create', () => {
expect(asyncForm).toBeTruthy();
});
it('should destroy asyncForm', () => {
asyncForm.destroy();
expect(asyncForm._eventManager._registeredListeners.length).toBe(0);
expect(asyncForm._element.classList).not.toContain(ASYNC_FORM_INITIALIZED_CLASS);
});
it('should throw if called without an element', () => {
expect(() => {
new AsyncForm();
}).toThrow();
});
});