diff options
| author | Fuwn <[email protected]> | 2024-06-19 09:17:36 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-19 09:17:36 +0000 |
| commit | 6d92ea622bfc98a831a9b94f19896fe0c215f794 (patch) | |
| tree | 34a8341128580cc190caecb16e9c62e2eb1f72ec /tests | |
| parent | feat(germ): bump version (diff) | |
| download | germ-0.4.2.tar.xz germ-0.4.2.zip | |
fix(ast): parse preformatted gemtext as preformatted contentv0.4.2
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ast.rs | 69 | ||||
| -rw-r--r-- | tests/node.rs | 4 |
2 files changed, 19 insertions, 54 deletions
diff --git a/tests/ast.rs b/tests/ast.rs index f95591a..021fd96 100644 --- a/tests/ast.rs +++ b/tests/ast.rs @@ -18,69 +18,34 @@ #[cfg(test)] mod test { - use germ::ast::{Ast, Node}; - - const EXAMPLE_GEMTEXT: &str = r#"```This is alt-text -Here goes the pre-formatted text. - -This continues the pre-formatted text on a new line after a blank line. -``` - -# This is a heading - -This is some text. - -This is more text after a blank line. - -* This is a single list item. -* This is the next list item. - -* This is a new list. -* This is the next item on the new list. - -## This is a sub-heading - -> This is a blockquote. - -### This is a sub-sub-heading. - -=> gemini://gem.rest/ This is a link to GemRest -=> /somewhere - -That was a link without text."#; + use germ::{ + ast::{Ast, Node}, + EXAMPLE_GEMTEXT, + }; #[test] fn build_multi_line_list_with_text() { - assert_eq!( - *Ast::from_string("* item1\n* 2\nhi text").inner(), - vec![ - Node::List(vec!["item1".to_string(), "2".to_string()]), - Node::Text("hi text".to_string()), - ], - ); + assert_eq!(*Ast::from_string("* item1\n* 2\nhi text").inner(), vec![ + Node::List(vec!["item1".to_string(), "2".to_string()]), + Node::Text("hi text".to_string()), + ],); } #[test] fn build_multi_line_vec() { - assert_eq!( - *Ast::from_string("=> /test hi\nhi there\n> hi").inner(), - vec![ - Node::Link { to: "/test".to_string(), text: Some("hi".to_string()) }, - Node::Text("hi there".to_string()), - Node::Blockquote("hi".to_string()), - ], - ); + assert_eq!(*Ast::from_string("=> /test hi\nhi there\n> hi").inner(), vec![ + Node::Link { to: "/test".to_string(), text: Some("hi".to_string()) }, + Node::Text("hi there".to_string()), + Node::Blockquote("hi".to_string()), + ],); } #[test] fn build_single_0th_from_vec() { - assert_eq!( - Ast::from_string("=> /test hi").inner(), - &vec![Node::Link { - to: "/test".to_string(), - text: Some("hi".to_string()), - }], - ); + assert_eq!(Ast::from_string("=> /test hi").inner(), &vec![Node::Link { + to: "/test".to_string(), + text: Some("hi".to_string()), + }],); } #[test] diff --git a/tests/node.rs b/tests/node.rs index ff224a4..0faf8c3 100644 --- a/tests/node.rs +++ b/tests/node.rs @@ -4,8 +4,8 @@ mod test { fn node_to_gemtext() { assert_eq!( germ::ast::Node::Link { - to: "/faq".to_string(), - text: Some("FAQ".to_string()) + to: "/faq".to_string(), + text: Some("FAQ".to_string()), } .to_gemtext(), "=> /faq FAQ", |