mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-20 01:56:37 +03:00
detect test: import resolution against platform-form paths
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vau2X53xGTjjTCXWMVBoNY
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
1d506359d7
commit
7d87d6e257
@@ -547,15 +547,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn imports() {
|
||||
let files = vec!["/p/a.tsx".to_string(), "/p/b/index.css".to_string()];
|
||||
assert_eq!(
|
||||
resolve_import("./a", "/p", &files).as_deref(),
|
||||
Some("/p/a.tsx")
|
||||
);
|
||||
assert_eq!(
|
||||
resolve_import("./b", "/p", &files).as_deref(),
|
||||
Some("/p/b/index.css")
|
||||
);
|
||||
assert_eq!(resolve_import("react", "/p", &files), None);
|
||||
// Paths in the platform's own form: the resolver joins with Node's
|
||||
// `path` semantics for the host, so a POSIX root would never match the
|
||||
// file set on Windows.
|
||||
let root = if cfg!(windows) { "C:\\p" } else { "/p" };
|
||||
let a = jsp::join(&[root, "a.tsx"]);
|
||||
let b_index = jsp::join(&[root, "b", "index.css"]);
|
||||
let files = vec![a.clone(), b_index.clone()];
|
||||
assert_eq!(resolve_import("./a", root, &files).as_deref(), Some(a.as_str()));
|
||||
assert_eq!(resolve_import("./b", root, &files).as_deref(), Some(b_index.as_str()));
|
||||
assert_eq!(resolve_import("react", root, &files), None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user