From 37b3db9654952a56bfb01bd52d83e1939e8e40d7 Mon Sep 17 00:00:00 2001 From: ayushcodes10 Date: Mon, 14 Sep 2026 14:46:46 +0530 Subject: [PATCH] Add a test for cross file resolution through a split export A single name import must resolve to its own split node, and a call made through it must resolve too, not just the import edge on its own. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh (cherry picked from commit 78a3ca4bf7a2ebdd1871b4ca2a7457daadb7d2b3) --- tests/test_js_destructured_export.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_js_destructured_export.py b/tests/test_js_destructured_export.py index 8dc75e9f5..b558443c3 100644 --- a/tests/test_js_destructured_export.py +++ b/tests/test_js_destructured_export.py @@ -39,3 +39,23 @@ def test_exported_destructure_emits_one_node_per_name(tmp_path): assert not any(label.startswith("{") for label in labels), ( f"a combined-pattern label survived: {sorted(labels)}" ) + + +def test_single_name_import_resolves_to_its_own_node(tmp_path): + r, lbl = _extract(tmp_path, { + "auth.ts": _NEXTAUTH_HELPER + + "export const { auth, handlers } = NextAuth({});\n", + "consumer.ts": ( + "import { auth } from './auth';\n" + "export function useAuth() { return auth(); }\n" + ), + }) + imports = [(lbl.get(e["source"]), lbl.get(e["target"])) + for e in r["edges"] if e["relation"] == "imports"] + assert ("consumer.ts", "auth") in imports, \ + f"import {{'auth'}} did not resolve to its own node; imports={imports}" + + calls = [(lbl.get(e["source"]), lbl.get(e["target"])) + for e in r["edges"] if e["relation"] == "calls"] + assert ("useAuth()", "auth") in calls, \ + f"call through the destructured import did not resolve; calls={calls}"