diff options
Diffstat (limited to 'tests')
15 files changed, 173 insertions, 0 deletions
diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index 25a0c8663..f78bea92d 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -8,6 +8,7 @@ use test_util::itest; use url::Url; use util::assert_contains; use util::assert_not_contains; +use util::env_vars_for_jsr_npm_tests; use util::env_vars_for_jsr_tests; use util::TestContextBuilder; @@ -477,3 +478,19 @@ fn set_lockfile_pkg_integrity( .unwrap() .integrity = integrity.to_string(); } + +itest!(jsx_with_no_pragmas { + args: "run jsr/jsx_with_no_pragmas/main.ts", + output: "jsr/jsx_with_no_pragmas/main.out", + envs: env_vars_for_jsr_npm_tests(), + http_server: true, + exit_code: 1, +}); + +itest!(jsx_with_pragmas { + args: "run jsr/jsx_with_pragmas/main.ts", + output: "jsr/jsx_with_pragmas/main.out", + envs: env_vars_for_jsr_npm_tests(), + http_server: true, + exit_code: 0, +}); diff --git a/tests/testdata/jsr/jsx_with_no_pragmas/main.out b/tests/testdata/jsr/jsx_with_no_pragmas/main.out new file mode 100644 index 000000000..c3977fe22 --- /dev/null +++ b/tests/testdata/jsr/jsx_with_no_pragmas/main.out @@ -0,0 +1,7 @@ +Download [WILDCARD] +error: Uncaught (in promise) ReferenceError: React is not defined + return renderToString(<div>foo.jsx</div>); + ^ + at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx:4:25) + at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts:5:15) + at file:///[WILDCARD]/jsr/jsx_with_no_pragmas/main.ts:3:1 diff --git a/tests/testdata/jsr/jsx_with_no_pragmas/main.ts b/tests/testdata/jsr/jsx_with_no_pragmas/main.ts new file mode 100644 index 000000000..9d6e5a41e --- /dev/null +++ b/tests/testdata/jsr/jsx_with_no_pragmas/main.ts @@ -0,0 +1,3 @@ +import { render } from "jsr:@denotest/jsx-with-no-pragmas@1.0.0"; + +render(); diff --git a/tests/testdata/jsr/jsx_with_pragmas/main.out b/tests/testdata/jsr/jsx_with_pragmas/main.out new file mode 100644 index 000000000..c149ba010 --- /dev/null +++ b/tests/testdata/jsr/jsx_with_pragmas/main.out @@ -0,0 +1,3 @@ +Download [WILDCARD] +<div>foo.jsx</div> +<div>foo.tsx</div> diff --git a/tests/testdata/jsr/jsx_with_pragmas/main.ts b/tests/testdata/jsr/jsx_with_pragmas/main.ts new file mode 100644 index 000000000..4a38c56ad --- /dev/null +++ b/tests/testdata/jsr/jsx_with_pragmas/main.ts @@ -0,0 +1,3 @@ +import { render } from "jsr:@denotest/jsx-with-pragmas@1.0.0"; + +render(); diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx new file mode 100644 index 000000000..ae310a74e --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx @@ -0,0 +1,5 @@ +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.jsx</div>); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.tsx b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.tsx new file mode 100644 index 000000000..021c2d49e --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.tsx @@ -0,0 +1,5 @@ +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.tsx</div>); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts new file mode 100644 index 000000000..05c549f64 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts @@ -0,0 +1,7 @@ +import renderJsx from "./foo.jsx"; +import renderTsx from "./foo.tsx"; + +export function render() { + console.log(renderJsx()); + console.log(renderTsx()); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0_meta.json b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0_meta.json new file mode 100644 index 000000000..417950442 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0_meta.json @@ -0,0 +1,40 @@ +{ + "exports": { + ".": "./mod.ts" + }, + "moduleGraph1": { + "/mod.ts": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 35]], + "specifier": "./foo.jsx", + "specifierRange": [[0, 22], [0, 33]] + }, { + "type": "static", + "kind": "import", + "range": [[1, 0], [1, 25]], + "specifier": "./foo.tsx", + "specifierRange": [[1, 22], [1, 33]] + }] + }, + "/foo.jsx": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 60]], + "specifier": "npm:preact-render-to-string", + "specifierRange": [[0, 32], [0, 60]] + }] + }, + "/foo.tsx": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 60]], + "specifier": "npm:preact-render-to-string", + "specifierRange": [[0, 32], [0, 60]] + }] + } + } +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/meta.json b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/meta.json new file mode 100644 index 000000000..02601e4d0 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/meta.json @@ -0,0 +1,5 @@ +{ + "versions": { + "1.0.0": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.jsx b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.jsx new file mode 100644 index 000000000..463fdb015 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.jsx @@ -0,0 +1,7 @@ +/** @jsxRuntime automatic *//** @jsxImportSource npm:preact */ +// deno-fmt-ignore-file +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.jsx</div>); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.tsx b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.tsx new file mode 100644 index 000000000..b34f2952e --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.tsx @@ -0,0 +1,7 @@ +/** @jsxRuntime automatic *//** @jsxImportSource npm:preact */ +// deno-fmt-ignore-file +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.tsx</div>); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/mod.ts b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/mod.ts new file mode 100644 index 000000000..05c549f64 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/mod.ts @@ -0,0 +1,7 @@ +import renderJsx from "./foo.jsx"; +import renderTsx from "./foo.tsx"; + +export function render() { + console.log(renderJsx()); + console.log(renderTsx()); +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0_meta.json b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0_meta.json new file mode 100644 index 000000000..fd1a63e60 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0_meta.json @@ -0,0 +1,52 @@ +{ + "exports": { + ".": "./mod.ts" + }, + "moduleGraph1": { + "/mod.ts": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 35]], + "specifier": "./foo.jsx", + "specifierRange": [[0, 22], [0, 33]] + }, { + "type": "static", + "kind": "import", + "range": [[1, 0], [1, 25]], + "specifier": "./foo.tsx", + "specifierRange": [[1, 22], [1, 33]] + }] + }, + "/foo.jsx": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 60]], + "specifier": "npm:preact/jsx-runtime", + "specifierRange": [[0, 32], [0, 60]] + }, { + "type": "static", + "kind": "import", + "range": [[2, 0], [2, 60]], + "specifier": "npm:preact-render-to-string", + "specifierRange": [[2, 32], [2, 60]] + }] + }, + "/foo.tsx": { + "dependencies": [{ + "type": "static", + "kind": "import", + "range": [[0, 0], [0, 60]], + "specifier": "npm:preact/jsx-runtime", + "specifierRange": [[0, 32], [0, 60]] + }, { + "type": "static", + "kind": "import", + "range": [[2, 0], [2, 60]], + "specifier": "npm:preact-render-to-string", + "specifierRange": [[2, 32], [2, 60]] + }] + } + } +} diff --git a/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/meta.json b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/meta.json new file mode 100644 index 000000000..02601e4d0 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/meta.json @@ -0,0 +1,5 @@ +{ + "versions": { + "1.0.0": {} + } +} |