Files
notifications-admin/tests/javascripts/errorBanner.test.js
Alex Janousek 3a39d910b3 Feat/webpack (#2998)
* First commit

* Removed govuk for webpack. Modernized javascript importing. Removed dead js

* Fixed tests, a few styling bugs

* Fixed some table errors and regenerated backstop ref images

* Updated tests for coverage

* Changes from carlo suggestions
2025-10-14 13:20:58 -04:00

45 lines
1.4 KiB
JavaScript

beforeAll(() => {
// ErrorBanner module sets window.NotifyModules.ErrorBanner for backward compatibility
require('../../app/assets/javascripts/errorBanner.js');
});
afterAll(() => {
require('./support/teardown.js');
});
describe("Error Banner", () => {
afterEach(() => {
document.body.innerHTML = '';
});
describe("The `hideBanner` method", () => {
test("Will hide the element", () => {
document.body.innerHTML = `
<span class="usa-error-message banner-dangerous js-error-visible">
</span>`;
window.NotifyModules.ErrorBanner.hideBanner();
expect(document.querySelector('.banner-dangerous').classList).toContain('display-none')
});
});
describe("The `showBanner` method", () => {
beforeEach(() => {
document.body.innerHTML = `
<span class="usa-error-message banner-dangerous js-error-visible display-none">
</span>`;
window.NotifyModules.ErrorBanner.showBanner('Some Err');
});
test("Will show the element", () => {
expect(document.querySelector('.banner-dangerous').classList).not.toContain('display-none')
});
});
test("Module exports ErrorBanner to window.NotifyModules", () => {
expect(window.NotifyModules.ErrorBanner).toBeDefined();
expect(window.NotifyModules.ErrorBanner.hideBanner).toBeDefined();
expect(window.NotifyModules.ErrorBanner.showBanner).toBeDefined();
});
});