Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(semantic): add JSXIdentifierReference-related tests #5224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let Component = () => <div></div>;
<Component></Component>
42 changes: 42 additions & 0 deletions crates/oxc_semantic/tests/fixtures/oxc/jsx/element-name.snap
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let A = {};

<A.B.C></A.B.C>;
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
]
2 changes: 1 addition & 1 deletion crates/oxc_semantic/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down