diff options
| author | 2022-07-18 16:31:14 +0200 | |
|---|---|---|
| committer | 2022-07-18 16:31:14 +0200 | |
| commit | 5403261e8213f68633a09fc3e9bc2e6e2cd777b2 (patch) | |
| tree | bb3a6419ef42f7611c2cb24fe7024228f579331b /tests/autolink.rs | |
| parent | 03544cafaa82ba4bd7e0bc3372fc59549a8dc0cc (diff) | |
| download | markdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.tar.gz markdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.tar.bz2 markdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.zip | |
Add support for turning off constructs
Diffstat (limited to 'tests/autolink.rs')
| -rw-r--r-- | tests/autolink.rs | 40 | 
1 files changed, 24 insertions, 16 deletions
| diff --git a/tests/autolink.rs b/tests/autolink.rs index 7396c7a..b6258e6 100644 --- a/tests/autolink.rs +++ b/tests/autolink.rs @@ -1,14 +1,14 @@  extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; - -const DANGER: &Options = &Options { -    allow_dangerous_html: true, -    allow_dangerous_protocol: true, -    default_line_ending: None, -}; +use micromark::{micromark, micromark_with_options, Constructs, Options};  #[test]  fn autolink() { +    let danger = Options { +        allow_dangerous_html: true, +        allow_dangerous_protocol: true, +        ..Options::default() +    }; +      assert_eq!(          micromark("<http://foo.bar.baz>"),          "<p><a href=\"http://foo.bar.baz\">http://foo.bar.baz</a></p>", @@ -40,7 +40,7 @@ fn autolink() {      );      assert_eq!( -        micromark_with_options("<a+b+c:d>", DANGER), +        micromark_with_options("<a+b+c:d>", &danger),          "<p><a href=\"a+b+c:d\">a+b+c:d</a></p>",          "should support protocol autolinks w/ incorrect URIs (1, danger)"      ); @@ -52,7 +52,7 @@ fn autolink() {      );      assert_eq!( -        micromark_with_options("<made-up-scheme://foo,bar>", DANGER), +        micromark_with_options("<made-up-scheme://foo,bar>", &danger),          "<p><a href=\"made-up-scheme://foo,bar\">made-up-scheme://foo,bar</a></p>",          "should support protocol autolinks w/ incorrect URIs (2, danger)"      ); @@ -64,7 +64,7 @@ fn autolink() {      );      assert_eq!( -        micromark_with_options("<localhost:5001/foo>", DANGER), +        micromark_with_options("<localhost:5001/foo>", &danger),          "<p><a href=\"localhost:5001/foo\">localhost:5001/foo</a></p>",          "should support protocol autolinks w/ incorrect URIs (4)"      ); @@ -246,10 +246,18 @@ fn autolink() {          "should not support a dash before a dot in email autolinks"      ); -    // To do: turning things off. -    // assert_eq!( -    //   micromark("<a@b.co>", {extensions: [{disable: {null: ["autolink"]}}]}), -    //   "<p><a@b.co></p>", -    //   "should support turning off autolinks" -    // ); +    assert_eq!( +        micromark_with_options( +            "<a@b.co>", +            &Options { +                constructs: Constructs { +                    autolink: false, +                    ..Constructs::default() +                }, +                ..Options::default() +            } +        ), +        "<p><a@b.co></p>", +        "should support turning off autolinks" +    );  } | 
