use super::*; // Simple transformer to make testing easier. fn test_parse_html(source: &str) -> Vec { parse_html(source).unwrap().lines.into() } #[test] fn test_parse_plain_text() { assert_eq!( test_parse_html("Some"), vec![FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("Some"), ])] ); assert_eq!( test_parse_html("

Some

tests

"), vec![ FormattedTextLine::Line(vec![FormattedTextFragment::plain_text("Some"),]), FormattedTextLine::Line(vec![FormattedTextFragment::plain_text("tests"),]) ] ); // Example from GDocs. assert_eq!( test_parse_html( "\

Some plain

\ text

" ), vec![ FormattedTextLine::Line(vec![FormattedTextFragment::plain_text("Some plain"),]), FormattedTextLine::Line(vec![FormattedTextFragment::plain_text("text"),]) ] ); } #[test] fn test_parse_text_styles() { assert_eq!( test_parse_html( "Some" ), vec![FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("So"), FormattedTextFragment::bold("me"), ])] ); assert_eq!( test_parse_html( "

Some

tests

" ), vec![ FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("So"), FormattedTextFragment::bold("me") ]), FormattedTextLine::Line(vec![ FormattedTextFragment::bold_italic("tes"), FormattedTextFragment::plain_text("ts") ]) ] ); assert_eq!( test_parse_html( "\

So\ \ me\ p\ lain\

t\ ext
" ), vec![ FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("So"), FormattedTextFragment::italic("me"), FormattedTextFragment::bold_italic("p"), FormattedTextFragment::bold("la"), FormattedTextFragment::plain_text("in") ]), FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("t"), FormattedTextFragment::italic("ext") ]) ] ); assert_eq!( test_parse_html( "\

This is underlined

\ text

" ), vec![ FormattedTextLine::Line(vec![FormattedTextFragment::underline("This is underlined")]), FormattedTextLine::Line(vec![FormattedTextFragment::plain_text(" text")]), ] ); assert_eq!( test_parse_html( "abc NewLinadafekene ghi def" ), vec![FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("abc "), FormattedTextFragment::hyperlink("NewLinadafekene", "https://google.com/"), FormattedTextFragment::plain_text(" ghi def") ]),] ); assert_eq!( test_parse_html( r#"the <ul> and <li>"# ), vec![FormattedTextLine::Line(vec![ FormattedTextFragment::plain_text("the "), FormattedTextFragment::inline_code("