Expand test coverage

This commit is contained in:
Juno Takano 2026-01-19 01:45:54 -03:00
commit 5151c53a2b
20 changed files with 773 additions and 121 deletions

View file

@ -15,29 +15,6 @@ pub struct Anchor {
}
impl Anchor {
pub fn new(
text: &str,
destination: &str,
node: Option<Node>,
node_id: Option<String>,
leading: bool,
external: bool,
balanced: bool,
) -> Anchor {
let mut anchor = Anchor {
text: text.to_owned(),
destination: Some(String::from(destination)),
node,
node_id,
leading,
external,
balanced,
};
anchor.route();
anchor
}
pub fn text(&self) -> String {
self.text.clone()
}
@ -287,4 +264,18 @@ mod tests {
anchor.route(); // set_destination also called this
assert!(anchor.destination().is_none());
}
#[test]
fn set_node_id() {
let payload = "kxBDJ0EoDVaygxpZ8NgNdQrUIBsGimTs";
let mut anchor = Anchor::default();
anchor.set_node_id(payload);
assert_eq!(anchor.node_id.unwrap(), payload);
}
#[test]
fn display_no_destination() {
let anchor = Anchor::default();
assert_eq!(format!("{anchor}"), "Anchor <empty> -> <unknown>");
}
}