Emoji-related tests

This commit is contained in:
projectmoon 2024-03-22 12:27:59 +01:00
parent 9958783e62
commit c17e030d05
1 changed files with 53 additions and 1 deletions

View File

@ -456,7 +456,7 @@ mod gemfeed_tests {
}
#[test]
fn parse_gemfeed_valid_if_has_title_with_emoji() -> Result<()> {
fn parse_gemfeed_valid_if_has_title_with_emoji_at_start() -> Result<()> {
let gemfeed: String = r#"
# 🖊 My Gemfeed
@ -481,6 +481,58 @@ mod gemfeed_tests {
Ok(())
}
#[test]
fn parse_gemfeed_valid_if_has_title_with_emoji_in_middle() -> Result<()> {
let gemfeed: String = r#"
# My 🖊 Gemfeed
This is a gemfeed with a title.
=> atom.xml Atom Feed
## Posts
=> post2.gmi 2023-03-05 Post 2
=> post1.gmi 2023-02-01 Post 1
"#
.lines()
.map(|line| line.trim_start())
.map(|line| format!("{}\n", line))
.collect();
let base_url = Url::parse("gemini://example.com/posts")?;
let ast = GemtextAst::from_string(gemfeed);
let result = Gemfeed::load_from_ast(&base_url, &ast);
assert!(matches!(result, Ok(_)));
Ok(())
}
#[test]
fn parse_gemfeed_valid_if_has_title_with_emoji_at_end() -> Result<()> {
let gemfeed: String = r#"
# My Gemfeed 🖊
This is a gemfeed with a title.
=> atom.xml Atom Feed
## Posts
=> post2.gmi 2023-03-05 Post 2
=> post1.gmi 2023-02-01 Post 1
"#
.lines()
.map(|line| line.trim_start())
.map(|line| format!("{}\n", line))
.collect();
let base_url = Url::parse("gemini://example.com/posts")?;
let ast = GemtextAst::from_string(gemfeed);
let result = Gemfeed::load_from_ast(&base_url, &ast);
assert!(matches!(result, Ok(_)));
Ok(())
}
#[test]
fn parse_gemfeed_ignores_non_post_links() -> Result<()> {
let gemfeed: String = r#"