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/alerts/alerts.spec.js

35 lines
762 B
JavaScript

import { Alerts, ALERTS_INITIALIZED_CLASS } from './alerts';
const MOCK_APP = {
httpClient: {
addResponseInterceptor: () => {},
removeResponseInterceptor: () => {},
},
};
describe('Alerts', () => {
let alerts;
beforeEach(() => {
const element = document.createElement('div');
alerts = new Alerts(element, MOCK_APP);
});
it('should create', () => {
expect(alerts).toBeTruthy();
});
it('should destory alerts', () => {
alerts.destroy();
expect(alerts._eventManager._registeredListeners.length).toBe(0);
expect(alerts._element.classList).not.toContain(ALERTS_INITIALIZED_CLASS);
});
it('should throw if called without an element', () => {
expect(() => {
new Alerts();
}).toThrow();
});
});