UNPKG

@tamagui/react-native-web-lite

Version:
45 lines (44 loc) 1.23 kB
import Dimensions from "../index.mjs"; describe("apis/Dimensions/index.js", () => { test("get", () => { expect(Dimensions.get("screen")).toMatchInlineSnapshot(` { "fontScale": 1, "height": 0, "scale": 1, "width": 0, } `); expect(Dimensions.get("window")).toMatchInlineSnapshot(` { "fontScale": 1, "height": 768, "scale": 1, "width": 1024, } `); }); test("set", () => { expect(() => Dimensions.set({})).toThrow(); }); test("addEventListener", () => { const handler = jest.fn(); const subscription = Dimensions.addEventListener("change", handler); Dimensions._update(); expect(handler).toHaveBeenCalledTimes(1); expect(handler).toHaveBeenLastCalledWith({ window: Dimensions.get("window"), screen: Dimensions.get("screen") }); subscription.remove(); Dimensions._update(); expect(handler).toHaveBeenCalledTimes(1); }); test("removeEventListener", () => { const handler = jest.fn(); Dimensions.removeEventListener("change", handler); Dimensions._update(); expect(handler).toHaveBeenCalledTimes(0); }); }); //# sourceMappingURL=index-test.mjs.map