From 8774b207b7251730eaa7fbfe4f144122a472dda0 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 22 Aug 2022 16:16:59 +0200 Subject: Add support for GFM task list item --- tests/gfm_task_list_item.rs | 236 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 tests/gfm_task_list_item.rs (limited to 'tests/gfm_task_list_item.rs') diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs new file mode 100644 index 0000000..5db5d1b --- /dev/null +++ b/tests/gfm_task_list_item.rs @@ -0,0 +1,236 @@ +extern crate micromark; +use micromark::{micromark, micromark_with_options, Constructs, Options}; +use pretty_assertions::assert_eq; + +#[test] +fn gfm_task_list_item() { + let gfm = Options { + constructs: Constructs::gfm(), + ..Options::default() + }; + + assert_eq!( + micromark("* [x] y."), + "", + "should ignore task list item checks by default" + ); + + assert_eq!( + micromark_with_options("* [x] y.", &gfm), + "", + "should support task list item checks" + ); + + assert_eq!( + micromark_with_options("* [ ] z.", &gfm), + "", + "should support unchecked task list item checks" + ); + + assert_eq!( + micromark_with_options("*\n [x]", &gfm), + "", + "should not support laziness (1)" + ); + + assert_eq!( + micromark_with_options("*\n[x]", &gfm), + "\n

[x]

", + "should not support laziness (2)" + ); + + assert_eq!( + micromark_with_options( + &r###" +* [ ] foo +* [x] bar + +- [x] foo + - [ ] bar + - [x] baz +- [ ] bim + ++ [ ] Unchecked? + +* [x] Checked? + ++ [y] What is this even? + +- [n]: # + [ ] After a definition + ++ [ ] In a setext heading + ======================= + +* In the… + + [ ] Second paragraph + +- [ ] With a tab + ++ [X] With an upper case `x` + +- [ ] With two spaces + ++ [x] Two spaces indent + +* [x] Three spaces indent + +- [x] Four spaces indent + ++ [x] Five spaces indent + +[ ] here? + +* > [ ] here? + +- [ ]No space? + +Empty? + ++ [ ] + +Space after: + ++ [ ]␠ + +* [ ]␠Text. + +Tab after: + ++ [ ]␉ + +* [ ]␉Text. + +EOL after: + ++ [ ] + +* [ ] + Text. + +- + [ ] after blank? + ++ # [ ] ATX Heading + +> * [x] In a list in a block quote +"### + .replace('␠', " ") + .replace('␉', "\t"), + &gfm + ), + r###" + + + + + + + + + + + + + + +

[ ] here?

+ + +

Empty?

+ +

Space after:

+ + +

Tab after:

+ + +

EOL after:

+ + + + +
+ +
+"###, + "should handle things like GitHub" + ); +} -- cgit