UNPKG

react-native-web-internals

Version:

React Native for Web

27 lines (26 loc) 1.92 kB
import { createSheet } from "../dom"; describe("createSheet", function () { test("creates a sheet on the client", function () { var sheet = createSheet(); expect(sheet.id).toMatchInlineSnapshot('"react-native-stylesheet"'), expect(typeof sheet.getTextContent()).toBe("string"), expect(typeof sheet.insert).toBe("function"); }), test("supports multiple documents with same styles", function () { var sheet = createSheet(); sheet.insert(".test-sheet { opacity: 1 }", 3); var iframe = document.createElement("iframe"); document.body.appendChild(iframe); var iframeDoc = iframe.contentWindow.document, iframeRootTag = document.createElement("div"); iframeDoc.body.appendChild(iframeRootTag); var iframeSheet = createSheet(iframeRootTag); expect(sheet).not.toBe(iframeSheet), expect(iframeSheet.id).toMatchInlineSnapshot('"react-native-stylesheet"'), expect(typeof iframeSheet.insert).toBe("function"), expect(iframeDoc.getElementById("react-native-stylesheet")).not.toBe(null), expect(iframeSheet.getTextContent().includes("test-sheet")).toBe(!0), sheet.insert(".test-iframe { opacity: 0 }", 3), expect(iframeSheet.getTextContent().includes("test-iframe")).toBe(!0); var div = document.createElement("div"), shadowRoot = div.attachShadow({ mode: "open" }), shadowRootTag = document.createElement("div"); shadowRoot.appendChild(shadowRootTag), document.body.appendChild(shadowRoot); var shadowSheet = createSheet(shadowRootTag); expect(sheet).not.toBe(shadowSheet), expect(shadowSheet.id).toMatchInlineSnapshot('"react-native-stylesheet"'), expect(typeof shadowSheet.insert).toBe("function"), expect(shadowSheet.getTextContent().includes("test-sheet")).toBe(!0), sheet.insert(".test-shadow { opacity: 0 }", 3), expect(shadowSheet.getTextContent().includes("test-shadow")).toBe(!0); }); }); //# sourceMappingURL=dom-test.native.js.map