Skip to content

Commit

Permalink
test(table): added tests on table alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin271 committed Jan 21, 2024
1 parent 1c96537 commit 5e519d1
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
source: src/interpreter/tests.rs
description: " --- md\n\n| left default | left forced | centered | right | left default |\n| ------------ | :---------- | :------: | ----: | ------------ |\n| text | text | text | text | text |\n\n\n --- html\n\n<table>\n<thead>\n<tr>\n<th>left default</th>\n<th align=\"left\">left forced</th>\n<th align=\"center\">centered</th>\n<th align=\"right\">right</th>\n<th>left default</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>text</td>\n<td align=\"left\">text</td>\n<td align=\"center\">text</td>\n<td align=\"right\">text</td>\n<td>text</td>\n</tr>\n</tbody>\n</table>\n"
expression: interpret_md(text)
---
[
Spacer(
InvisibleSpacer(5),
),
Table(
Table {
headers: [
TextBox {
texts: [
Text {
text: "left default",
default_color: Color(BLACK),
style: BOLD ,
..
},
],
..
},
TextBox {
texts: [
Text {
text: "left forced",
default_color: Color(BLACK),
style: BOLD ,
..
},
],
..
},
TextBox {
align: Center,
texts: [
Text {
text: "centered",
default_color: Color(BLACK),
style: BOLD ,
..
},
],
..
},
TextBox {
align: Right,
texts: [
Text {
text: "right",
default_color: Color(BLACK),
style: BOLD ,
..
},
],
..
},
TextBox {
texts: [
Text {
text: "left default",
default_color: Color(BLACK),
style: BOLD ,
..
},
],
..
},
],
rows: [
[
TextBox {
texts: [
Text {
text: "text",
default_color: Color(BLACK),
..
},
],
..
},
TextBox {
texts: [
Text {
text: "text",
default_color: Color(BLACK),
..
},
],
..
},
TextBox {
align: Center,
texts: [
Text {
text: "text",
default_color: Color(BLACK),
..
},
],
..
},
TextBox {
align: Right,
texts: [
Text {
text: "text",
default_color: Color(BLACK),
..
},
],
..
},
TextBox {
texts: [
Text {
text: "text",
default_color: Color(BLACK),
..
},
],
..
},
],
],
},
),
Spacer(
InvisibleSpacer(5),
),
]
7 changes: 7 additions & 0 deletions src/interpreter/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ tags:
# Markdown h1 header
";

const ALIGNED_TABLE: &str = "\
| left default | left forced | centered | right | left default |
| ------------ | :---------- | :------: | ----: | ------------ |
| text | text | text | text | text |
";

snapshot_interpreted_elements!(
(footnotes_list_prefix, FOOTNOTES_LIST_PREFIX),
(checklist_has_no_text_prefix, CHECKLIST_HAS_NO_TEXT_PREFIX),
Expand All @@ -234,6 +240,7 @@ snapshot_interpreted_elements!(
(para_in_ordered_list, PARA_IN_ORDERED_LIST),
(code_in_ordered_list, CODE_IN_ORDERED_LIST),
(yaml_frontmatter, YAML_FRONTMATTER),
(aligned_table, ALIGNED_TABLE),
);

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

0 comments on commit 5e519d1

Please sign in to comment.