mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
test(semantic): add JSXIdentifierReference-related tests (#5224)
These tests demonstrate what kind of JSX will have references.
This commit is contained in:
parent
7e2a7afaa4
commit
be7b8c6845
5 changed files with 82 additions and 1 deletions
2
crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.jsx
vendored
Normal file
2
crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.jsx
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let Component = () => <div></div>;
|
||||
<Component></Component>
|
||||
42
crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.snap
vendored
Normal file
42
crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.snap
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
source: crates/oxc_semantic/tests/main.rs
|
||||
input_file: crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.jsx
|
||||
---
|
||||
[
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"children": [],
|
||||
"flags": "ScopeFlags(StrictMode | Function | Arrow)",
|
||||
"id": 1,
|
||||
"node": "ArrowFunctionExpression",
|
||||
"symbols": []
|
||||
}
|
||||
],
|
||||
"flags": "ScopeFlags(StrictMode | Top)",
|
||||
"id": 0,
|
||||
"node": "Program",
|
||||
"symbols": [
|
||||
{
|
||||
"flags": "SymbolFlags(BlockScopedVariable | ArrowFunction)",
|
||||
"id": 0,
|
||||
"name": "Component",
|
||||
"node": "VariableDeclarator(Component)",
|
||||
"references": [
|
||||
{
|
||||
"flags": "ReferenceFlags(Read)",
|
||||
"id": 0,
|
||||
"name": "Component",
|
||||
"node_id": 19
|
||||
},
|
||||
{
|
||||
"flags": "ReferenceFlags(Read)",
|
||||
"id": 1,
|
||||
"name": "Component",
|
||||
"node_id": 22
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
3
crates/oxc_semantic/tests/fixtures/oxc/jsx/member-expression.jsx
vendored
Normal file
3
crates/oxc_semantic/tests/fixtures/oxc/jsx/member-expression.jsx
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let A = {};
|
||||
|
||||
<A.B.C></A.B.C>;
|
||||
34
crates/oxc_semantic/tests/fixtures/oxc/jsx/member-expression.snap
vendored
Normal file
34
crates/oxc_semantic/tests/fixtures/oxc/jsx/member-expression.snap
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
source: crates/oxc_semantic/tests/main.rs
|
||||
input_file: crates/oxc_semantic/tests/fixtures/oxc/jsx/member-expression.jsx
|
||||
---
|
||||
[
|
||||
{
|
||||
"children": [],
|
||||
"flags": "ScopeFlags(StrictMode | Top)",
|
||||
"id": 0,
|
||||
"node": "Program",
|
||||
"symbols": [
|
||||
{
|
||||
"flags": "SymbolFlags(BlockScopedVariable)",
|
||||
"id": 0,
|
||||
"name": "A",
|
||||
"node": "VariableDeclarator(A)",
|
||||
"references": [
|
||||
{
|
||||
"flags": "ReferenceFlags(Read)",
|
||||
"id": 0,
|
||||
"name": "A",
|
||||
"node_id": 13
|
||||
},
|
||||
{
|
||||
"flags": "ReferenceFlags(Read)",
|
||||
"id": 1,
|
||||
"name": "A",
|
||||
"node_id": 22
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -111,7 +111,7 @@ fn analyze(path: &Path, source_text: &str) -> String {
|
|||
/// cargo test --package oxc_semantic --test main
|
||||
#[test]
|
||||
fn main() {
|
||||
insta::glob!("fixtures/**/*.{ts,tsx}", |path| {
|
||||
insta::glob!("fixtures/**/*.{js,jsx,ts,tsx}", |path| {
|
||||
let source_text = fs::read_to_string(path).unwrap();
|
||||
let snapshot = analyze(path, &source_text);
|
||||
let name = path.file_stem().unwrap().to_str().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue