react-native-web-internals
Version:
React Native for Web
25 lines (24 loc) • 1.97 kB
JavaScript
;
var import_dom = require("../dom");
describe("createSheet", function() {
test("creates a sheet on the client", function() {
var sheet = (0, import_dom.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 = (0, import_dom.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 = (0, import_dom.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 = (0, import_dom.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.js.map