diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 10:40:01 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 10:40:01 +0200 |
commit | ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a (patch) | |
tree | 2da4be3be22c2324c48cb17133b3f4b26b9139d2 /tests/mdx_expression_flow.rs | |
parent | 861af95c119721e814460fa7dc32bd3d74b38484 (diff) | |
download | markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.tar.gz markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.tar.bz2 markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.zip |
Rename crate to `markdown`
Diffstat (limited to 'tests/mdx_expression_flow.rs')
-rw-r--r-- | tests/mdx_expression_flow.rs | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/tests/mdx_expression_flow.rs b/tests/mdx_expression_flow.rs index 8217c94..b181ef7 100644 --- a/tests/mdx_expression_flow.rs +++ b/tests/mdx_expression_flow.rs @@ -1,8 +1,8 @@ -extern crate micromark; +extern crate markdown; mod test_utils; -use micromark::{ +use markdown::{ mdast::{MdxFlowExpression, Node, Root}, - micromark_to_mdast, micromark_with_options, + to_html_with_options, to_mdast, unist::Position, Constructs, Options, ParseOptions, }; @@ -20,49 +20,49 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { }; assert_eq!( - micromark_with_options("{a}", &mdx)?, + to_html_with_options("{a}", &mdx)?, "", "should support an expression" ); assert_eq!( - micromark_with_options("{}", &mdx)?, + to_html_with_options("{}", &mdx)?, "", "should support an empty expression" ); assert_eq!( - micromark_with_options("{a", &mdx).err().unwrap(), + to_html_with_options("{a", &mdx).err().unwrap(), "1:3: Unexpected end of file in expression, expected a corresponding closing brace for `{`", "should crash if no closing brace is found (1)" ); assert_eq!( - micromark_with_options("{b { c }", &mdx).err().unwrap(), + to_html_with_options("{b { c }", &mdx).err().unwrap(), "1:9: Unexpected end of file in expression, expected a corresponding closing brace for `{`", "should crash if no closing brace is found (2)" ); assert_eq!( - micromark_with_options("{\n}\na", &mdx)?, + to_html_with_options("{\n}\na", &mdx)?, "<p>a</p>", "should support a line ending in an expression" ); assert_eq!( - micromark_with_options("{ a } \t\nb", &mdx)?, + to_html_with_options("{ a } \t\nb", &mdx)?, "<p>b</p>", "should support expressions followed by spaces" ); assert_eq!( - micromark_with_options(" { a }\nb", &mdx)?, + to_html_with_options(" { a }\nb", &mdx)?, "<p>b</p>", "should support expressions preceded by spaces" ); assert_eq!( - micromark_with_options("> {a\nb}", &mdx) + to_html_with_options("> {a\nb}", &mdx) .err() .unwrap(), "2:1: Unexpected lazy line in expression in container, expected line to be prefixed with `>` when in a block quote, whitespace when in a list, etc", @@ -70,19 +70,19 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { ); assert_eq!( - micromark_with_options("> a\n{b}", &mdx)?, + to_html_with_options("> a\n{b}", &mdx)?, "<blockquote>\n<p>a</p>\n</blockquote>\n", "should not support lazyness (2)" ); assert_eq!( - micromark_with_options("> {a}\nb", &mdx)?, + to_html_with_options("> {a}\nb", &mdx)?, "<blockquote>\n</blockquote>\n<p>b</p>", "should not support lazyness (3)" ); assert_eq!( - micromark_with_options("> {\n> a\nb}", &mdx) + to_html_with_options("> {\n> a\nb}", &mdx) .err() .unwrap(), "3:1: Unexpected lazy line in expression in container, expected line to be prefixed with `>` when in a block quote, whitespace when in a list, etc", @@ -90,7 +90,7 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("{alpha +\nbravo}", &mdx.parse)?, + to_mdast("{alpha +\nbravo}", &mdx.parse)?, Node::Root(Root { children: vec![Node::MdxFlowExpression(MdxFlowExpression { value: "alpha +\nbravo".into(), @@ -118,61 +118,61 @@ fn mdx_expression_flow_gnostic() -> Result<(), String> { }; assert_eq!( - micromark_with_options("{a}", &swc)?, + to_html_with_options("{a}", &swc)?, "", "should support an expression" ); assert_eq!( - micromark_with_options("{}", &swc)?, + to_html_with_options("{}", &swc)?, "", "should support an empty expression" ); assert_eq!( - micromark_with_options("{a", &swc).err().unwrap(), + to_html_with_options("{a", &swc).err().unwrap(), "1:3: Unexpected end of file in expression, expected a corresponding closing brace for `{`", "should crash if no closing brace is found (1)" ); assert_eq!( - micromark_with_options("{b { c }", &swc).err().unwrap(), + to_html_with_options("{b { c }", &swc).err().unwrap(), "1:4: Could not parse expression with swc: Unexpected content after expression", "should crash if no closing brace is found (2)" ); assert_eq!( - micromark_with_options("{\n}\na", &swc)?, + to_html_with_options("{\n}\na", &swc)?, "<p>a</p>", "should support a line ending in an expression" ); assert_eq!( - micromark_with_options("{ a } \t\nb", &swc)?, + to_html_with_options("{ a } \t\nb", &swc)?, "<p>b</p>", "should support expressions followed by spaces" ); assert_eq!( - micromark_with_options(" { a }\nb", &swc)?, + to_html_with_options(" { a }\nb", &swc)?, "<p>b</p>", "should support expressions preceded by spaces" ); assert_eq!( - micromark_with_options(" {`\n a\n `}", &swc)?, + to_html_with_options(" {`\n a\n `}", &swc)?, "", "should support indented expressions" ); assert_eq!( - micromark_with_options("a{(b)}c", &swc)?, + to_html_with_options("a{(b)}c", &swc)?, "<p>ac</p>", "should support expressions padded w/ parens" ); assert_eq!( - micromark_with_options("a{/* b */ ( (c) /* d */ + (e) )}f", &swc)?, + to_html_with_options("a{/* b */ ( (c) /* d */ + (e) )}f", &swc)?, "<p>af</p>", "should support expressions padded w/ parens and comments" ); @@ -193,47 +193,43 @@ fn mdx_expression_spread() -> Result<(), String> { }; assert_eq!( - micromark_with_options("<a {...b} />", &swc)?, + to_html_with_options("<a {...b} />", &swc)?, "", "should support spreads for attribute expression" ); assert_eq!( - micromark_with_options("<a {b} />", &swc).err().unwrap(), + to_html_with_options("<a {b} />", &swc).err().unwrap(), "1:5: Expected a single spread value, such as `...x`", "should crash if not a spread" ); assert_eq!( - micromark_with_options("<a {...?} />", &swc).err().unwrap(), + to_html_with_options("<a {...?} />", &swc).err().unwrap(), "1:13: Could not parse expression with swc: Unexpected token `?`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier", "should crash on an incorrect spread" ); assert_eq!( - micromark_with_options("<a {...b,c} d>", &swc) - .err() - .unwrap(), + to_html_with_options("<a {...b,c} d>", &swc).err().unwrap(), "1:5: Expected a single spread value, such as `...x`", "should crash if a spread and other things" ); assert_eq!( - micromark_with_options("<a {} />", &swc).err().unwrap(), + to_html_with_options("<a {} />", &swc).err().unwrap(), "1:5: Expected a single spread value, such as `...x`", "should crash on an empty spread" ); assert_eq!( - micromark_with_options("<a {a=b} />", &swc).err().unwrap(), + to_html_with_options("<a {a=b} />", &swc).err().unwrap(), "1:12: Could not parse expression with swc: assignment property is invalid syntax", "should crash if not an identifier" ); assert_eq!( - micromark_with_options("<a {/* b */} />", &swc) - .err() - .unwrap(), + to_html_with_options("<a {/* b */} />", &swc).err().unwrap(), "1:5: Expected a single spread value, such as `...x`", "should crash on a comment spread" ); |