diff options
Diffstat (limited to 'cli/tests/testdata/compiler_api_test.ts')
-rw-r--r-- | cli/tests/testdata/compiler_api_test.ts | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/cli/tests/testdata/compiler_api_test.ts b/cli/tests/testdata/compiler_api_test.ts index 9870908d1..42d6f54eb 100644 --- a/cli/tests/testdata/compiler_api_test.ts +++ b/cli/tests/testdata/compiler_api_test.ts @@ -557,3 +557,81 @@ Deno.test({ assertEquals(sourceMap.sourcesContent.length, 1); }, }); + +Deno.test({ + name: "Deno.emit() - JSX import source pragma", + async fn() { + const { files } = await Deno.emit( + "file:///a.tsx", + { + sources: { + "file:///a.tsx": `/** @jsxImportSource https://example.com/jsx */ + + export function App() { + return ( + <div><></></div> + ); + }`, + "https://example.com/jsx/jsx-runtime": `export function jsx( + _type, + _props, + _key, + _source, + _self, + ) {} + export const jsxs = jsx; + export const jsxDEV = jsx; + export const Fragment = Symbol("Fragment"); + console.log("imported", import.meta.url); + `, + }, + }, + ); + assert(files["file:///a.tsx.js"]); + assert( + files["file:///a.tsx.js"].startsWith( + `import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`, + ), + ); + }, +}); + +Deno.test({ + name: "Deno.emit() - JSX import source no pragma", + async fn() { + const { files } = await Deno.emit( + "file:///a.tsx", + { + compilerOptions: { + jsx: "react-jsx", + jsxImportSource: "https://example.com/jsx", + }, + sources: { + "file:///a.tsx": `export function App() { + return ( + <div><></></div> + ); + }`, + "https://example.com/jsx/jsx-runtime": `export function jsx( + _type, + _props, + _key, + _source, + _self, + ) {} + export const jsxs = jsx; + export const jsxDEV = jsx; + export const Fragment = Symbol("Fragment"); + console.log("imported", import.meta.url); + `, + }, + }, + ); + assert(files["file:///a.tsx.js"]); + assert( + files["file:///a.tsx.js"].startsWith( + `import { Fragment as _Fragment, jsx as _jsx } from "https://example.com/jsx/jsx-runtime";\n`, + ), + ); + }, +}); |