UNPKG

@tamagui/react-native-web-lite

Version:
83 lines 4.62 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod)); var import_react = __toESM(require("react"), 1), import__ = __toESM(require("../index.cjs"), 1); const NoopComponent = () => import_react.default.createElement("div"); describe("AppRegistry", () => { describe("runApplication", () => { let rootTag; beforeEach(() => { rootTag = document.createElement("div"), rootTag.id = "react-root", document.body.appendChild(rootTag); }), afterEach(() => { document.body.removeChild(rootTag); }), test("callback after render", () => { const callback = jest.fn(); import__.default.registerComponent("App", () => NoopComponent), import__.default.runApplication("App", { initialProps: {}, rootTag, callback }), expect(callback).toHaveBeenCalledTimes(1); }), test("styles roots in different documents", () => { import__.default.registerComponent("App", () => NoopComponent), import__.default.runApplication("App", { initialProps: {}, rootTag }); const iframe = document.createElement("iframe"); document.body.appendChild(iframe); const iframeRootTag = document.createElement("div"); iframeRootTag.id = "react-iframe-root", iframe.contentWindow.document.body.appendChild(iframeRootTag), import__.default.registerComponent("App", () => NoopComponent), import__.default.runApplication("App", { initialProps: {}, rootTag: iframeRootTag }); const iframedoc = iframeRootTag.ownerDocument; expect(iframedoc).toBe(iframe.contentWindow.document), expect(iframedoc).not.toBe(document); const cssText = Array.prototype.slice.call(iframedoc.getElementById("react-native-stylesheet").sheet.cssRules).map(cssRule => cssRule.cssText); expect(cssText).toMatchInlineSnapshot(` [ "[stylesheet-group=\\"0\\"] {}", "body {margin: 0;}", "button::-moz-focus-inner,input::-moz-focus-inner {border: 0; padding: 0;}", "html {-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(0,0,0,0);}", "input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration {display: none;}", "[stylesheet-group=\\"1\\"] {}", ".css-view-175oi2r {align-items: stretch; background-color: rgba(0,0,0,0.00); border: 0 solid black; box-sizing: border-box; display: flex; flex-basis: auto; flex-direction: column; flex-shrink: 0; list-style: none; margin: 0px; min-height: 0px; min-width: 0px; padding: 0px; position: relative; text-decoration: none; z-index: 0;}", "[stylesheet-group=\\"2\\"] {}", ".r-display-xoduu5 {display: inline-flex;}", ".r-flex-13awgt0 {flex: 1;}", "[stylesheet-group=\\"2.2\\"] {}", ".r-bottom-1p0dtai {bottom: 0px;}", ".r-left-1d2f490 {left: 0px;}", ".r-pointerEvents-105ug2t {pointer-events: auto !important;}", ".r-pointerEvents-12vffkv>* {pointer-events: auto;}", ".r-pointerEvents-12vffkv {pointer-events: none !important;}", ".r-pointerEvents-633pao {pointer-events: none !important;}", ".r-pointerEvents-ah5dr5>* {pointer-events: none;}", ".r-pointerEvents-ah5dr5 {pointer-events: auto !important;}", ".r-position-u8s1d {position: absolute;}", ".r-right-zchlnj {right: 0px;}", ".r-top-ipm5af {top: 0px;}", ] `); }); }); });