7 scrape_text_for_mentions,
13 fn test_mentions_regex() {
14 let text = "Just read a great blog post by [@tedu@honk.teduangst.com](/u/test). And another by !test_community@fish.teduangst.com . Another [@lemmy@lemmy-alpha:8540](/u/fish)";
15 let mentions = scrape_text_for_mentions(text);
17 assert_eq!(mentions[0].name, "tedu".to_string());
18 assert_eq!(mentions[0].domain, "honk.teduangst.com".to_string());
19 assert_eq!(mentions[1].domain, "lemmy-alpha:8540".to_string());
23 fn test_valid_actor_name() {
24 assert!(is_valid_actor_name("Hello_98"));
25 assert!(is_valid_actor_name("ten"));
26 assert!(!is_valid_actor_name("Hello-98"));
27 assert!(!is_valid_actor_name("a"));
28 assert!(!is_valid_actor_name(""));
32 fn test_valid_display_name() {
33 assert!(is_valid_display_name("hello @there"));
34 assert!(!is_valid_display_name("@hello there"));
36 // Make sure zero-space with an @ doesn't work
37 assert!(!is_valid_display_name(&format!(
44 fn test_valid_post_title() {
45 assert!(is_valid_post_title("Post Title"));
46 assert!(is_valid_post_title(" POST TITLE 😃😃😃😃😃"));
47 assert!(!is_valid_post_title("\n \n \n \n ")); // tabs/spaces/newlines
51 fn test_valid_matrix_id() {
52 assert!(is_valid_matrix_id("@dess:matrix.org"));
53 assert!(!is_valid_matrix_id("dess:matrix.org"));
54 assert!(!is_valid_matrix_id(" @dess:matrix.org"));
55 assert!(!is_valid_matrix_id("@dess:matrix.org t"));
59 fn test_slur_filter() {
61 "faggot test kike tranny cocksucker retardeds. Capitalized Niggerz. This is a bunch of other safe text.";
62 let slur_free = "No slurs here";
65 "*removed* test *removed* *removed* *removed* *removed*. Capitalized *removed*. This is a bunch of other safe text."
69 let has_slurs_vec = vec![
77 let has_slurs_err_str = "No slurs - Niggerz, cocksucker, faggot, kike, retardeds, tranny";
79 assert_eq!(slur_check(test), Err(has_slurs_vec));
80 assert_eq!(slur_check(slur_free), Ok(()));
81 if let Err(slur_vec) = slur_check(test) {
82 assert_eq!(&slurs_vec_to_str(slur_vec), has_slurs_err_str);
86 // These helped with testing
88 // fn test_send_email() {
89 // let result = send_email("not a subject", "test_email@gmail.com", "ur user", "<h1>HI there</h1>");
90 // assert!(result.is_ok());