@tamagui/react-native-web-lite
Version:
React Native for Web
36 lines (35 loc) • 1.24 kB
JavaScript
import Dimensions from "..";
describe("apis/Dimensions/index.js", function () {
test("get", function () {
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", function () {
expect(function () {
return Dimensions.set({});
}).toThrow();
}), test("addEventListener", function () {
var handler = jest.fn(),
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", function () {
var handler = jest.fn();
Dimensions.removeEventListener("change", handler), Dimensions._update(), expect(handler).toHaveBeenCalledTimes(0);
});
});
//# sourceMappingURL=index-test.native.js.map