mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-12 18:36:49 +00:00
34 lines
827 B
JavaScript
34 lines
827 B
JavaScript
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
|
|
import { Application } from "stimulus";
|
|
import flash_controller from "../../../app/webpacker/controllers/flash_controller";
|
|
|
|
describe("FlashController", () => {
|
|
beforeAll(() => {
|
|
const application = Application.start();
|
|
application.register("flash", flash_controller);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
document.body.innerHTML = `
|
|
<div id="element" data-controller='flash' data-flash-auto-close-value='true'></div>
|
|
`;
|
|
});
|
|
|
|
describe("autoClose", () => {
|
|
jest.useFakeTimers();
|
|
|
|
it("is cleared after about 5 seconds", () => {
|
|
let element = document.getElementById("element");
|
|
expect(element).not.toBe(null);
|
|
|
|
jest.advanceTimersByTime(5500);
|
|
|
|
element = document.getElementById("element");
|
|
expect(element).toBe(null);
|
|
});
|
|
});
|
|
});
|