2021-07-20 12:14:10 +01:00
|
|
|
beforeAll(() => {
|
|
|
|
|
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 = `
|
2023-06-08 13:12:00 -04:00
|
|
|
<span class="usa-error-message banner-dangerous js-error-visible">
|
2021-07-20 12:14:10 +01:00
|
|
|
</span>`;
|
|
|
|
|
window.GOVUK.ErrorBanner.hideBanner();
|
2023-08-25 10:40:56 -04:00
|
|
|
expect(document.querySelector('.banner-dangerous').classList).toContain('display-none')
|
2021-07-20 12:14:10 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("The `showBanner` method", () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
document.body.innerHTML = `
|
2023-08-25 10:40:56 -04:00
|
|
|
<span class="usa-error-message banner-dangerous js-error-visible display-none">
|
2021-07-20 12:14:10 +01:00
|
|
|
</span>`;
|
|
|
|
|
|
|
|
|
|
window.GOVUK.ErrorBanner.showBanner('Some Err');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("Will show the element", () => {
|
2023-08-25 10:40:56 -04:00
|
|
|
expect(document.querySelector('.banner-dangerous').classList).not.toContain('display-none')
|
2021-07-20 12:14:10 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|