aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mdx_swc.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 15:57:55 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 15:57:55 +0200
commitcd5bb2d16c6b28332b0b6077b27b2b90a8051896 (patch)
tree848ebc6200b80d2dfdcd67bf0bb245eea06bb24f /tests/mdx_swc.rs
parent6e80e03bb6d6af47aba2b339f160e4895ab5afba (diff)
downloadmarkdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.tar.gz
markdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.tar.bz2
markdown-rs-cd5bb2d16c6b28332b0b6077b27b2b90a8051896.zip
Refactor to split parse from compile options
Diffstat (limited to 'tests/mdx_swc.rs')
-rw-r--r--tests/mdx_swc.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/mdx_swc.rs b/tests/mdx_swc.rs
index 74f975a..d4b8e46 100644
--- a/tests/mdx_swc.rs
+++ b/tests/mdx_swc.rs
@@ -1,44 +1,47 @@
extern crate micromark;
mod test_utils;
-use micromark::{micromark_with_options, Constructs, Options};
+use micromark::{micromark_with_options, Constructs, Options, ParseOptions};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_swc() -> Result<(), String> {
- let mdx = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ let swc = Options {
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
assert_eq!(
- micromark_with_options("{'}'}", &mdx)?,
+ micromark_with_options("{'}'}", &swc)?,
"",
"should support JavaScript-aware flow expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("a {'}'} b", &mdx)?,
+ micromark_with_options("a {'}'} b", &swc)?,
"<p>a b</p>",
"should support JavaScript-aware text expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("<a {...a/*}*/} />", &mdx)?,
+ micromark_with_options("<a {...a/*}*/} />", &swc)?,
"",
"should support JavaScript-aware attribute expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("<a b={'}'} />", &mdx)?,
+ micromark_with_options("<a b={'}'} />", &swc)?,
"",
"should support JavaScript-aware attribute value expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &mdx)?,
+ micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &swc)?,
"<h1>c</h1>",
"should support JavaScript-aware ESM w/ `mdx_esm_parse`"
);