aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gfm_task_list_item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gfm_task_list_item.rs')
-rw-r--r--tests/gfm_task_list_item.rs57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs
index b824730..ae6c548 100644
--- a/tests/gfm_task_list_item.rs
+++ b/tests/gfm_task_list_item.rs
@@ -1,5 +1,8 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Constructs, Options};
+use micromark::{
+ mdast::{List, ListItem, Node, Paragraph, Position, Root, Text},
+ micromark, micromark_to_mdast, micromark_with_options, Constructs, Options,
+};
use pretty_assertions::assert_eq;
#[test]
@@ -240,5 +243,57 @@ Text.</li>
"should handle things like GitHub"
);
+ assert_eq!(
+ micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm)?,
+ Node::Root(Root {
+ children: vec![Node::List(List {
+ ordered: false,
+ spread: false,
+ start: None,
+ children: vec![
+ Node::ListItem(ListItem {
+ checked: Some(true),
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "a".to_string(),
+ position: Some(Position::new(1, 7, 6, 1, 8, 7))
+ }),],
+ position: Some(Position::new(1, 7, 6, 1, 8, 7))
+ })],
+ position: Some(Position::new(1, 1, 0, 1, 8, 7))
+ }),
+ Node::ListItem(ListItem {
+ checked: Some(false),
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "b".to_string(),
+ position: Some(Position::new(2, 7, 14, 2, 8, 15))
+ }),],
+ position: Some(Position::new(2, 7, 14, 2, 8, 15))
+ })],
+ position: Some(Position::new(2, 1, 8, 2, 8, 15))
+ }),
+ Node::ListItem(ListItem {
+ checked: None,
+ spread: false,
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Text(Text {
+ value: "c".to_string(),
+ position: Some(Position::new(3, 3, 18, 3, 4, 19))
+ }),],
+ position: Some(Position::new(3, 3, 18, 3, 4, 19))
+ })],
+ position: Some(Position::new(3, 1, 16, 3, 4, 19))
+ }),
+ ],
+ position: Some(Position::new(1, 1, 0, 3, 4, 19))
+ })],
+ position: Some(Position::new(1, 1, 0, 3, 4, 19))
+ }),
+ "should support task list items as `checked` fields on `ListItem`s in mdast"
+ );
+
Ok(())
}