use super::*;
fn linker_with(patterns: &[&str]) -> Linker {
let store = Store::at(std::env::temp_dir().join("aube-public-hoist-test"));
let strs: Vec<String> = patterns.iter().map(|s| s.to_string()).collect();
Linker::new(&store, LinkStrategy::Copy).with_public_hoist_pattern(&strs)
}
#[test]
fn empty_pattern_matches_nothing() {
let l = linker_with(&[]);
assert!(!l.public_hoist_matches("react"));
assert!(!l.public_hoist_matches("eslint"));
}
#[test]
fn wildcard_matches_substring() {
let l = linker_with(&["*eslint*", "*prettier*"]);
assert!(l.public_hoist_matches("eslint"));
assert!(l.public_hoist_matches("eslint-plugin-react"));
assert!(l.public_hoist_matches("@typescript-eslint/parser"));
assert!(l.public_hoist_matches("prettier"));
assert!(!l.public_hoist_matches("react"));
}
#[test]
fn exact_name_match() {
let l = linker_with(&["react"]);
assert!(l.public_hoist_matches("react"));
assert!(!l.public_hoist_matches("react-dom"));
}
#[test]
fn negation_excludes_positive_match() {
let l = linker_with(&["*eslint*", "!eslint-config-*"]);
assert!(l.public_hoist_matches("eslint"));
assert!(l.public_hoist_matches("eslint-plugin-react"));
assert!(!l.public_hoist_matches("eslint-config-next"));
}
#[test]
fn case_insensitive() {
let l = linker_with(&["*ESLINT*"]);
assert!(l.public_hoist_matches("eslint"));
assert!(l.public_hoist_matches("ESLint"));
}
#[test]
fn invalid_patterns_are_silently_dropped() {
let l = linker_with(&["[unterminated", "react"]);
assert!(l.public_hoist_matches("react"));
assert!(!l.public_hoist_matches("eslint"));
}