Add a test for bold inside a radio target.
This commit is contained in:
parent
e4c6ca2880
commit
4ba1e63dde
@ -120,6 +120,7 @@ mod tests {
|
|||||||
use crate::parser::parser_context::ContextTree;
|
use crate::parser::parser_context::ContextTree;
|
||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::source::Source;
|
use crate::parser::source::Source;
|
||||||
|
use crate::parser::Bold;
|
||||||
use crate::parser::PlainText;
|
use crate::parser::PlainText;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -151,4 +152,40 @@ mod tests {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bold_radio_target() {
|
||||||
|
let input = "foo *bar* baz";
|
||||||
|
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
||||||
|
let document_context = initial_context
|
||||||
|
.with_additional_node(ContextElement::DocumentRoot(input))
|
||||||
|
.with_additional_node(ContextElement::RadioTarget(vec![vec![Object::Bold(
|
||||||
|
Bold {
|
||||||
|
source: "*bar*",
|
||||||
|
children: vec![Object::PlainText(PlainText { source: "bar" })],
|
||||||
|
},
|
||||||
|
)]]));
|
||||||
|
let paragraph_matcher = parser_with_context!(element(true))(&document_context);
|
||||||
|
let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph");
|
||||||
|
let first_paragraph = match first_paragraph {
|
||||||
|
crate::parser::Element::Paragraph(paragraph) => paragraph,
|
||||||
|
_ => panic!("Should be a paragraph!"),
|
||||||
|
};
|
||||||
|
assert_eq!(remaining, "");
|
||||||
|
assert_eq!(first_paragraph.get_source(), "foo *bar* baz");
|
||||||
|
assert_eq!(first_paragraph.children.len(), 3);
|
||||||
|
assert_eq!(
|
||||||
|
first_paragraph
|
||||||
|
.children
|
||||||
|
.get(1)
|
||||||
|
.expect("Len already asserted to be 3"),
|
||||||
|
&Object::RadioLink(RadioLink {
|
||||||
|
source: "*bar*",
|
||||||
|
children: vec![Object::Bold(Bold {
|
||||||
|
source: "*bar*",
|
||||||
|
children: vec![Object::PlainText(PlainText { source: "bar" })]
|
||||||
|
})]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user