Skip to content

Commit

Permalink
properly bind jest.it
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored and nicolo-ribaudo committed Sep 25, 2023
1 parent da5e835 commit aaf9d5b
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions packages/babel-standalone/test/transform-script-tags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { createRequire } from "module";
import { itGte } from "$repo-utils";
const require = createRequire(import.meta.url);

const nodeGte16 = itGte("16.0.0");

describe("transformScriptTags", () => {
let standaloneSource;
let JSDOM;
Expand All @@ -15,28 +13,31 @@ describe("transformScriptTags", () => {
);
JSDOM = require("jsdom").JSDOM;
});
nodeGte16("should transform script element with type 'text/babel'", () => {
const dom = new JSDOM(
`<!DOCTYPE html><head><script>${standaloneSource}</script><script type="text/babel">globalThis ?? window</script></head>`,
{ runScripts: "dangerously" },
);
return new Promise((resolve, reject) => {
dom.window.addEventListener("DOMContentLoaded", () => {
try {
const transformedScriptElement =
dom.window.document.head.children.item(2);
expect(transformedScriptElement.getAttribute("type")).toBeNull();
expect(transformedScriptElement.innerHTML).toContain(
"globalThis !== null && globalThis !== void 0 ? globalThis : window",
);
resolve();
} catch (err) {
reject(err);
}
itGte("16.0.0")(
"should transform script element with type 'text/babel'",
() => {
const dom = new JSDOM(
`<!DOCTYPE html><head><script>${standaloneSource}</script><script type="text/babel">globalThis ?? window</script></head>`,
{ runScripts: "dangerously" },
);
return new Promise((resolve, reject) => {
dom.window.addEventListener("DOMContentLoaded", () => {
try {
const transformedScriptElement =
dom.window.document.head.children.item(2);
expect(transformedScriptElement.getAttribute("type")).toBeNull();
expect(transformedScriptElement.innerHTML).toContain(
"globalThis !== null && globalThis !== void 0 ? globalThis : window",
);
resolve();
} catch (err) {
reject(err);
}
});
});
});
});
nodeGte16(
},
);
itGte("16.0.0")(
"should pass through the nonce attribute to the transformed script element",
() => {
const nonceAttribute = "nonce_example";
Expand Down

0 comments on commit aaf9d5b

Please sign in to comment.