mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
test(jsr): add tests for jsx files with and without pragmas (#22634)
Follow up to https://github.com/denoland/deno/pull/22631 that asserts behavior when JSX and TSX files have and do not have pragmas with `jsx*` config.
This commit is contained in:
parent
8d9a54ca18
commit
a9aef0d017
15 changed files with 173 additions and 0 deletions
|
@ -8,6 +8,7 @@ use test_util::itest;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::assert_contains;
|
use util::assert_contains;
|
||||||
use util::assert_not_contains;
|
use util::assert_not_contains;
|
||||||
|
use util::env_vars_for_jsr_npm_tests;
|
||||||
use util::env_vars_for_jsr_tests;
|
use util::env_vars_for_jsr_tests;
|
||||||
use util::TestContextBuilder;
|
use util::TestContextBuilder;
|
||||||
|
|
||||||
|
@ -477,3 +478,19 @@ fn set_lockfile_pkg_integrity(
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.integrity = integrity.to_string();
|
.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,
|
||||||
|
});
|
||||||
|
|
7
tests/testdata/jsr/jsx_with_no_pragmas/main.out
vendored
Normal file
7
tests/testdata/jsr/jsx_with_no_pragmas/main.out
vendored
Normal file
|
@ -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
|
3
tests/testdata/jsr/jsx_with_no_pragmas/main.ts
vendored
Normal file
3
tests/testdata/jsr/jsx_with_no_pragmas/main.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { render } from "jsr:@denotest/jsx-with-no-pragmas@1.0.0";
|
||||||
|
|
||||||
|
render();
|
3
tests/testdata/jsr/jsx_with_pragmas/main.out
vendored
Normal file
3
tests/testdata/jsr/jsx_with_pragmas/main.out
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Download [WILDCARD]
|
||||||
|
<div>foo.jsx</div>
|
||||||
|
<div>foo.tsx</div>
|
3
tests/testdata/jsr/jsx_with_pragmas/main.ts
vendored
Normal file
3
tests/testdata/jsr/jsx_with_pragmas/main.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { render } from "jsr:@denotest/jsx-with-pragmas@1.0.0";
|
||||||
|
|
||||||
|
render();
|
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx
vendored
Normal file
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { renderToString } from "npm:preact-render-to-string";
|
||||||
|
|
||||||
|
export default function render() {
|
||||||
|
return renderToString(<div>foo.jsx</div>);
|
||||||
|
}
|
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.tsx
vendored
Normal file
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/foo.tsx
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { renderToString } from "npm:preact-render-to-string";
|
||||||
|
|
||||||
|
export default function render() {
|
||||||
|
return renderToString(<div>foo.tsx</div>);
|
||||||
|
}
|
7
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts
vendored
Normal file
7
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import renderJsx from "./foo.jsx";
|
||||||
|
import renderTsx from "./foo.tsx";
|
||||||
|
|
||||||
|
export function render() {
|
||||||
|
console.log(renderJsx());
|
||||||
|
console.log(renderTsx());
|
||||||
|
}
|
40
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0_meta.json
vendored
Normal file
40
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/1.0.0_meta.json
vendored
Normal file
|
@ -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]]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/meta.json
vendored
Normal file
5
tests/testdata/jsr/registry/@denotest/jsx-with-no-pragmas/meta.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"versions": {
|
||||||
|
"1.0.0": {}
|
||||||
|
}
|
||||||
|
}
|
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.jsx
vendored
Normal file
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.jsx
vendored
Normal file
|
@ -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>);
|
||||||
|
}
|
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.tsx
vendored
Normal file
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/foo.tsx
vendored
Normal file
|
@ -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>);
|
||||||
|
}
|
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/mod.ts
vendored
Normal file
7
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0/mod.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import renderJsx from "./foo.jsx";
|
||||||
|
import renderTsx from "./foo.tsx";
|
||||||
|
|
||||||
|
export function render() {
|
||||||
|
console.log(renderJsx());
|
||||||
|
console.log(renderTsx());
|
||||||
|
}
|
52
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0_meta.json
vendored
Normal file
52
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/1.0.0_meta.json
vendored
Normal file
|
@ -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]]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/meta.json
vendored
Normal file
5
tests/testdata/jsr/registry/@denotest/jsx-with-pragmas/meta.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"versions": {
|
||||||
|
"1.0.0": {}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue