Expand test coverage
This commit is contained in:
parent
3837af387a
commit
5958f1551b
27 changed files with 593 additions and 109 deletions
|
|
@ -207,6 +207,43 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leading_multiword_anchor() {
|
||||
assert_eq!(
|
||||
read("interactions are |basic elements| of systems"),
|
||||
r#"<p>interactions are <a href="/node/basic elements">basic elements</a> of systems</p>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_end_of_destination() {
|
||||
assert_eq!(
|
||||
read("interactions are |basic elements|BasicElements| of systems"),
|
||||
r#"<p>interactions are <a href="/node/BasicElements">basic elements</a> of systems</p>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_end_of_external_destination() {
|
||||
assert_eq!(
|
||||
read("this |anchor example|https://example.com| is external"),
|
||||
r#"<p>this <a href="https://example.com">anchor example</a> is external</p>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn anchor_destination_at_eoi() {
|
||||
assert_eq!(read("a |b c|d"), r#"<p>a <a href="/node/d">b c</a></p>"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_anchor_destination_at_eoi() {
|
||||
assert_eq!(
|
||||
read("a b|https://example.com"),
|
||||
r#"<p>a <a href="https://example.com">b</a></p>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nonleading_plural_anchor_at_eoi() {
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -85,7 +85,12 @@ pub fn parse(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{syntax::content::parser, types::Graph};
|
||||
use crate::{
|
||||
syntax::content::parser::{
|
||||
self, context::list::parse, lexeme::Lexeme, state::State,
|
||||
},
|
||||
types::{Config, Graph},
|
||||
};
|
||||
|
||||
fn read(input: &str) -> String {
|
||||
parser::read(input, &Graph::new(None).meta.config)
|
||||
|
|
@ -260,4 +265,21 @@ mod tests {
|
|||
</ul>\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected = "List context parser called to handle non-list context"
|
||||
)]
|
||||
fn bad_context() {
|
||||
let mut state = State::default();
|
||||
let lexemes = Lexeme::collect(&["a", "b", "c"].map(str::to_string));
|
||||
let config = Config::default();
|
||||
parse(
|
||||
&Lexeme::default(),
|
||||
&mut state,
|
||||
&mut vec![],
|
||||
&mut lexemes.iter().peekable(),
|
||||
&config,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue