UNPKG

@panoramax/web-viewer

Version:

Panoramax web viewer for geolocated pictures

56 lines (46 loc) 1.51 kB
import Loader from "../../../src/components/ui/Loader"; describe("constructor", () => { it("works", () => { const l = new Loader(); expect(l.isVisible()).toBe(true); }); }); describe("dismiss", () => { it("works on success", () => { const p = { dispatchEvent: jest.fn() }; const l = new Loader(); l._parent = p; l.dismiss(); expect(l.isVisible()).toBe(false); expect(p.dispatchEvent.mock.calls).toMatchSnapshot(); }); it("works on success + next fct", () => { const p = { dispatchEvent: jest.fn() }; const n = jest.fn(); const l = new Loader(); l._parent = p; l.dismiss(null, null, n); expect(l.isVisible()).toBe(false); expect(p.dispatchEvent.mock.calls).toMatchSnapshot(); expect(n.mock.calls).toMatchSnapshot(); }); it("works with error", () => { const p = { dispatchEvent: jest.fn(), _t: { pnx: {} } }; const l = new Loader(); l._parent = p; expect(() => l.dismiss(true, "an error")).toThrow(new Error("an error")) expect(l.isVisible()).toBe(true); expect(p.dispatchEvent.mock.calls).toMatchSnapshot(); }); it("works with error + next fct", () => { const p = { dispatchEvent: jest.fn(), _t: { pnx: {} } }; const n = jest.fn(); const l = new Loader(); l.addEventListener = jest.fn(); l._parent = p; expect(() => l.dismiss(true, "an error", n)).toThrow(new Error("an error")) expect(l.isVisible()).toBe(true); expect(p.dispatchEvent.mock.calls).toMatchSnapshot(); expect(l.addEventListener.mock.calls).toMatchSnapshot(); }); });