Skip to content

Commit

Permalink
Add tests for elements nested in a list item (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev authored Dec 2, 2023
1 parent c848a39 commit f6ebb7d
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
source: src/interpreter/tests.rs
description: " --- md\n\n1. 1st item\n\n ```rust\n fn main() {}\n ```\n\n2. 2nd item\n\n\n --- html\n\n<ol>\n<li>\n<p>1st item</p>\n<pre style=\"background-color:#f6f8fa;\"><code class=\"language-rust\"><span style=\"font-weight:bold;color:#a71d5d;\">fn </span><span style=\"font-weight:bold;color:#795da3;\">main</span><span style=\"color:#323232;\">() {}\n</span></code></pre>\n</li>\n<li>\n<p>2nd item</p>\n</li>\n</ol>\n"
expression: interpret_md(text)
---
[
TextBox(
TextBox {
indent: 50.0,
texts: [
Text {
text: "1. ",
default_color: Color(BLACK),
style: BOLD ,
..
},
Text {
text: "1st item",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
TextBox(
TextBox {
indent: 50.0,
background_color: Some(Color { r: 0.92, g: 0.94, b: 0.96 }),
is_code_block: true,
texts: [
Text {
text: "fn ",
font_family: Monospace,
color: Some(Color { r: 0.39, g: 0.01, b: 0.11 }),
style: BOLD ,
..
},
Text {
text: "main",
font_family: Monospace,
color: Some(Color { r: 0.19, g: 0.11, b: 0.37 }),
style: BOLD ,
..
},
Text {
text: "() {}",
font_family: Monospace,
color: Some(Color { r: 0.03, g: 0.03, b: 0.03 }),
..
},
Text {
text: "\n",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
TextBox(
TextBox {
indent: 50.0,
texts: [
Text {
text: "2. ",
default_color: Color(BLACK),
style: BOLD ,
..
},
Text {
text: "2nd item",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
Spacer(
InvisibleSpacer(5),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
source: src/interpreter/tests.rs
description: " --- md\n\n1. 1st item\n\n Nested paragraph\n\n2. 2nd item\n\n\n --- html\n\n<ol>\n<li>\n<p>1st item</p>\n<p>Nested paragraph</p>\n</li>\n<li>\n<p>2nd item</p>\n</li>\n</ol>\n"
expression: interpret_md(text)
---
[
TextBox(
TextBox {
indent: 50.0,
texts: [
Text {
text: "1. ",
default_color: Color(BLACK),
style: BOLD ,
..
},
Text {
text: "1st item",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
TextBox(
TextBox {
indent: 50.0,
texts: [
Text {
text: "Nested paragraph",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
TextBox(
TextBox {
indent: 50.0,
texts: [
Text {
text: "2. ",
default_color: Color(BLACK),
style: BOLD ,
..
},
Text {
text: "2nd item",
default_color: Color(BLACK),
..
},
],
..
},
),
Spacer(
InvisibleSpacer(5),
),
Spacer(
InvisibleSpacer(5),
),
]
20 changes: 20 additions & 0 deletions src/interpreter/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ const ORDERED_LIST_IN_UNORDERED: &str = "\
- bullet
";

const PARA_IN_ORDERED_LIST: &str = "\
1. 1st item
Nested paragraph
2. 2nd item
";

const CODE_IN_ORDERED_LIST: &str = "\
1. 1st item
```rust
fn main() {}
```
2. 2nd item
";

snapshot_interpreted_elements!(
(footnotes_list_prefix, FOOTNOTES_LIST_PREFIX),
(checklist_has_no_text_prefix, CHECKLIST_HAS_NO_TEXT_PREFIX),
Expand All @@ -195,6 +213,8 @@ snapshot_interpreted_elements!(
(unordered_list_in_ordered, UNORDERED_LIST_IN_ORDERED),
(nested_ordered_list, NESTED_ORDERED_LIST),
(ordered_list_in_unordered, ORDERED_LIST_IN_UNORDERED),
(para_in_ordered_list, PARA_IN_ORDERED_LIST),
(code_in_ordered_list, CODE_IN_ORDERED_LIST),
);

/// Spin up a server, so we can test network requests without external services
Expand Down

0 comments on commit f6ebb7d

Please sign in to comment.