🦠 The Definitive Gemini Protocol Toolkit
gemini gemini-protocol gemtext parser zero-dependency toolkit ast converter html markdown cli networking
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(Node): rename content() to to_gemtext()

This commit adds a `tests/node.rs` file to test `Node::to_gemtext`.

Fuwn ad1ae607 fe03915e

+38 -15
+2 -2
src/ast/node.rs
··· 173 173 } 174 174 175 175 impl Node { 176 - /// Obtain the Gemtext content of a single [`Node`] as a [`String`] 176 + /// Convert a single [`Node`] of any node type to a Gemtext [`String`] 177 177 #[must_use] 178 - pub fn content(&self) -> String { 178 + pub fn to_gemtext(&self) -> String { 179 179 super::Ast::from_nodes(vec![self.to_owned()]).to_gemtext() 180 180 } 181 181 }
+22 -13
tests/ast.rs
··· 51 51 52 52 #[test] 53 53 fn build_multi_line_list_with_text() { 54 - assert_eq!(*Ast::from_string("* item1\n* 2\nhi text").inner(), vec![ 55 - Node::List(vec!["item1".to_string(), "2".to_string()]), 56 - Node::Text("hi text".to_string()), 57 - ],); 54 + assert_eq!( 55 + *Ast::from_string("* item1\n* 2\nhi text").inner(), 56 + vec![ 57 + Node::List(vec!["item1".to_string(), "2".to_string()]), 58 + Node::Text("hi text".to_string()), 59 + ], 60 + ); 58 61 } 59 62 60 63 #[test] 61 64 fn build_multi_line_vec() { 62 - assert_eq!(*Ast::from_string("=> /test hi\nhi there\n> hi").inner(), vec![ 63 - Node::Link { to: "/test".to_string(), text: Some("hi".to_string()) }, 64 - Node::Text("hi there".to_string()), 65 - Node::Blockquote("hi".to_string()), 66 - ],); 65 + assert_eq!( 66 + *Ast::from_string("=> /test hi\nhi there\n> hi").inner(), 67 + vec![ 68 + Node::Link { to: "/test".to_string(), text: Some("hi".to_string()) }, 69 + Node::Text("hi there".to_string()), 70 + Node::Blockquote("hi".to_string()), 71 + ], 72 + ); 67 73 } 68 74 69 75 #[test] 70 76 fn build_single_0th_from_vec() { 71 - assert_eq!(Ast::from_string("=> /test hi").inner(), &vec![Node::Link { 72 - to: "/test".to_string(), 73 - text: Some("hi".to_string()), 74 - }],); 77 + assert_eq!( 78 + Ast::from_string("=> /test hi").inner(), 79 + &vec![Node::Link { 80 + to: "/test".to_string(), 81 + text: Some("hi".to_string()), 82 + }], 83 + ); 75 84 } 76 85 77 86 #[test]
+14
tests/node.rs
··· 1 + #[cfg(test)] 2 + mod test { 3 + #[test] 4 + fn node_to_gemtext() { 5 + assert_eq!( 6 + germ::ast::Node::Link { 7 + to: "/faq".to_string(), 8 + text: Some("FAQ".to_string()) 9 + } 10 + .to_gemtext(), 11 + "=> /faq FAQ", 12 + ); 13 + } 14 + }