Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Laux committed Oct 14, 2023
1 parent 1bbcc60 commit 778c823
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/parser/parse_from_text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ pub(crate) fn extract_mention_addresses(input: &str) -> Vec<String> {
if let Ok((rest, Element::Mention { address })) = text_elements::mention(remaining) {
result.push(address.to_owned());
remaining = rest;
} else if let Ok((_, rest)) = take_until::<&str, &str, CustomError<&str>>("@")(remaining) {
continue;
}
if let Ok((rest, _)) = take_until::<&str, &str, CustomError<&str>>(" @")(remaining) {
remaining = rest;
} else {
// there is no mention anymore in this message
break;
}
}
Expand Down
8 changes: 2 additions & 6 deletions tests/mentions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn extract_mentions() {
let mention_text = "Ping @[email protected] and @[email protected]!";
assert_eq!(
extract_mention_addresses(mention_text),
vec!["email@address.tld", "email1@address.tld"]
vec!["email1@address.tld", "email@address.tld"]
)
}

Expand All @@ -15,11 +15,7 @@ fn extract_mentions_are_deduped_and_sorted() {
"Ping @[email protected], @[email protected], @[email protected] and @[email protected]!\n@[email protected] your opinion would be especially helpful.";
assert_eq!(
extract_mention_addresses(mention_text),
vec![
"@[email protected]",
"[email protected]",
"[email protected]"
]
vec!["[email protected]", "[email protected]", "[email protected]"]
)
}

Expand Down

0 comments on commit 778c823

Please sign in to comment.