Skip to content

Commit

Permalink
test: update tests to use unimarkup_inline
Browse files Browse the repository at this point in the history
  • Loading branch information
nfejzic committed Jul 31, 2022
1 parent 5149c76 commit 53f5ca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion core/tests/backend/backend_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use unimarkup_core::{
elements::{HeadingBlock, HeadingLevel},
middleend::{self, AsIrLines, ContentIrLine},
};
use unimarkup_inline::ParseUnimarkupInlines;

use super::super::middleend::ir_test_setup;

Expand All @@ -15,7 +16,7 @@ fn test__backend_run__heading_block() {
let block = HeadingBlock {
id: "some-id".into(),
level: HeadingLevel::Level1,
content: "This is a heading".into(),
content: "This is a heading".parse_unimarkup_inlines().collect(),
attributes: "{}".into(),
line_nr: 0,
};
Expand Down
14 changes: 8 additions & 6 deletions core/tests/backend/inline_tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use unimarkup_core::{backend::Render, elements::ParagraphBlock};
use unimarkup_inline::ParseUnimarkupInlines;

#[test]
fn test__render_html__valid_escaped_inline() {
let id = String::from("paragraph-id");
let content = String::from("\\*23\\*3");
let content = "\\*23\\*3".parse_unimarkup_inlines().collect();

let mut block = ParagraphBlock {
id: id.clone(),
Expand All @@ -12,7 +13,7 @@ fn test__render_html__valid_escaped_inline() {
line_nr: 0,
};

let mut expected_html = format!("<p id='{}'>\\*23\\*3</p>", id);
let mut expected_html = format!("<p id='{}'>*23*3</p>", id);

let result = block.render_html();
assert!(result.is_ok(), "Cause: {:?}", result.unwrap_err());
Expand All @@ -22,8 +23,9 @@ fn test__render_html__valid_escaped_inline() {
"Html file does not match with expected output"
);

block.content = "\\ *italic*\\".to_string();
expected_html = format!("<p id='{}'>\\ <i>italic</i>\\</p>", id);
block.content = "\\ *italic*\\".parse_unimarkup_inlines().collect();
expected_html = format!("<p id='{}'> <em>italic</em></p>", id);

let result = block.render_html();
assert!(result.is_ok(), "Cause: {:?}", result.unwrap_err());
assert_eq!(
Expand All @@ -32,8 +34,8 @@ fn test__render_html__valid_escaped_inline() {
"Html file does not match with expected output"
);

block.content = "**\\*only bold\\***".to_string();
expected_html = format!("<p id='{}'><b>\\*only bold\\*</b></p>", id);
block.content = "**\\*only bold\\***".parse_unimarkup_inlines().collect();
expected_html = format!("<p id='{}'><strong>*only bold*</strong></p>", id);

let result = block.render_html();
assert!(result.is_ok(), "Cause: {:?}", result.unwrap_err());
Expand Down

0 comments on commit 53f5ca4

Please sign in to comment.