import { defineCE, fixture, fixtureCleanup, oneEvent } from "@open-wc/testing-helpers"; import { customElement, html, LitElement } from "lit-element"; import { ResizeMixin, ResizeObserver } from "./ResizeMixin"; interface MyWindow extends Window { ResizeObserver: typeof ResizeObserver; } const disconnectMock = jest.fn(); const observeMock = jest.fn(); const unobserveMock = jest.fn(); const constructorMock = jest.fn(); class MockObserver { public observe = observeMock; public unobserve = unobserveMock; public disconnect = disconnectMock; constructor() { constructorMock(); } } (window as MyWindow & typeof globalThis).ResizeObserver = jest.fn().mockImplementation(() => { return new MockObserver(); }); describe("Resize Mixin", () => { afterEach(fixtureCleanup); @customElement("custom-element") class CustomElement extends ResizeMixin(ResizeMixin(LitElement)) { connectedCallback() { super.connectedCallback(); this.dispatchEvent(new CustomEvent("connected-callback")); } customUnobserveAll() { super.unobserveAll && super.unobserveAll(); } customResize() { const fakeDOMRect = this.getBoundingClientRect(); super.handleResize && super.handleResize(fakeDOMRect); } render() { return html`