Skip to content

Commit

Permalink
chore: update rust test error
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Oct 14, 2024
1 parent 8a4ff25 commit 6e757f5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions crates/toolkit/src/resolve/path_start_with_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,24 @@ mod test {
fn test() {
let cwd = PathBuf::from("/root/src");

let alias = HashMap::from([
("/@".to_string(), cwd.to_string_lossy().to_string()),
("@".to_string(), cwd.to_string_lossy().to_string()),
("react$".to_string(), cwd.to_string_lossy().to_string()),
(
"$__farm_regex:^/(utils)$".to_string(),
cwd.join("$1").to_string_lossy().to_string(),
),
]);
let alias: Vec<AliasItem> = vec![
AliasItem::Complex {
find: StringOrRegex::String("/@".to_string()),
replacement: cwd.to_string_lossy().to_string(),
},
AliasItem::Complex {
find: StringOrRegex::String("@".to_string()),
replacement: cwd.to_string_lossy().to_string(),
},
AliasItem::Complex {
find: StringOrRegex::String("react$".to_string()),
replacement: cwd.to_string_lossy().to_string(),
},
AliasItem::Complex {
find: StringOrRegex::Regex(Regex::new("^/(utils)$").unwrap()),
replacement: cwd.join("$1").to_string_lossy().to_string(),
},
];

assert_eq!(is_start_with_alias(&alias, "/@/img/logo.png"), true);
assert_eq!(is_start_with_alias(&alias, "@/img/logo.png"), true);
Expand Down

0 comments on commit 6e757f5

Please sign in to comment.