Skip to content

Commit

Permalink
Merge pull request #1182 from epage/snapbox
Browse files Browse the repository at this point in the history
chore: Update to snapbox 0.6
  • Loading branch information
epage authored May 28, 2024
2 parents 08977af + a3a9061 commit 66dea35
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 65 deletions.
76 changes: 55 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ chrono = "0.4.38"

[dev-dependencies]
trycmd = "0.15"
snapbox = { version = "0.5.9", features = ["diff"] }
snapbox = { version = "0.6.5", features = ["diff"] }

[features]
default = ["syntax-highlight", "sass", "serve", "html-minifier"]
Expand Down
86 changes: 43 additions & 43 deletions src/syntax_highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ pub fn decorate_markdown<'a>(
mod test_syntsx {
use super::*;

use snapbox::assert_data_eq;
use snapbox::prelude::*;
use snapbox::str;

const CODE_BLOCK: &str = "mod test {
fn hello(arg: int) -> bool {
\
Expand All @@ -242,22 +246,18 @@ mod test_syntsx {
))
.unwrap();
let output = template.render(&liquid::Object::new());
let expected =
snapbox::str!["<pre style=\"background-color:#2b303b;\">\n\
<code><span style=\"color:#b48ead;\">mod </span>\
<span style=\"color:#c0c5ce;\">test {\n\
</span><span style=\"color:#c0c5ce;\"> </span>\
<span style=\"color:#b48ead;\">fn \
</span><span style=\"color:#8fa1b3;\">hello</span><span style=\"color:#c0c5ce;\">(\
</span><span style=\"color:#bf616a;\">arg</span><span style=\"color:#c0c5ce;\">: int) -&gt; \
</span><span style=\"color:#b48ead;\">bool </span><span style=\"color:#c0c5ce;\">{\n\
</span><span style=\"color:#c0c5ce;\"> \
</span><span style=\"color:#d08770;\">true\n\
</span><span style=\"color:#c0c5ce;\"> }\n\
</span><span style=\"color:#c0c5ce;\"> }\n\
</span><span style=\"color:#c0c5ce;\"> </span></code></pre>\n"];

snapbox::assert_eq(expected, output.unwrap());
let expected = str![[r#"
<pre style="background-color:#2b303b;">
<code><span style="color:#b48ead;">mod </span><span style="color:#c0c5ce;">test {
</span><span style="color:#c0c5ce;"> </span><span style="color:#b48ead;">fn </span><span style="color:#8fa1b3;">hello</span><span style="color:#c0c5ce;">(</span><span style="color:#bf616a;">arg</span><span style="color:#c0c5ce;">: int) -&gt; </span><span style="color:#b48ead;">bool </span><span style="color:#c0c5ce;">{
</span><span style="color:#c0c5ce;"> </span><span style="color:#d08770;">true
</span><span style="color:#c0c5ce;"> }
</span><span style="color:#c0c5ce;"> }
</span><span style="color:#c0c5ce;"> </span></code></pre>
"#]];

assert_data_eq!(output.unwrap(), expected.raw());
}

#[test]
Expand All @@ -276,23 +276,19 @@ mod test_syntsx {
&mut buf,
decorate_markdown(parser, syntax, Some("base16-ocean.dark")).unwrap(),
);
let expected =
snapbox::str!["<pre style=\"background-color:#2b303b;\">\n\
<code><span style=\"color:#b48ead;\">mod </span>\
<span style=\"color:#c0c5ce;\">test {\n\
</span><span style=\"color:#c0c5ce;\"> </span>\
<span style=\"color:#b48ead;\">fn \
</span><span style=\"color:#8fa1b3;\">hello</span><span style=\"color:#c0c5ce;\">(\
</span><span style=\"color:#bf616a;\">arg</span><span style=\"color:#c0c5ce;\">: int) -&gt; \
</span><span style=\"color:#b48ead;\">bool </span><span style=\"color:#c0c5ce;\">{\n\
</span><span style=\"color:#c0c5ce;\"> \
</span><span style=\"color:#d08770;\">true\n\
</span><span style=\"color:#c0c5ce;\"> }\n\
</span><span style=\"color:#c0c5ce;\"> }\n\
</span><span style=\"color:#c0c5ce;\"> \n\
</span></code></pre>\n"];

snapbox::assert_eq(expected, &buf);
let expected = str![[r#"
<pre style="background-color:#2b303b;">
<code><span style="color:#b48ead;">mod </span><span style="color:#c0c5ce;">test {
</span><span style="color:#c0c5ce;"> </span><span style="color:#b48ead;">fn </span><span style="color:#8fa1b3;">hello</span><span style="color:#c0c5ce;">(</span><span style="color:#bf616a;">arg</span><span style="color:#c0c5ce;">: int) -&gt; </span><span style="color:#b48ead;">bool </span><span style="color:#c0c5ce;">{
</span><span style="color:#c0c5ce;"> </span><span style="color:#d08770;">true
</span><span style="color:#c0c5ce;"> }
</span><span style="color:#c0c5ce;"> }
</span><span style="color:#c0c5ce;">
</span></code></pre>
"#]];

assert_data_eq!(&buf, expected.raw());
}
}

Expand All @@ -301,6 +297,10 @@ mod test_syntsx {
mod test_raw {
use super::*;

use snapbox::assert_data_eq;
use snapbox::prelude::*;
use snapbox::str;

const CODE_BLOCK: &str = "mod test {
fn hello(arg: int) -> bool {
\
Expand All @@ -325,17 +325,17 @@ mod test_raw {
))
.unwrap();
let output = template.render(&liquid::Object::new());
let expected = snapbox::str![
r#"<pre><code class="language-rust">mod test {
let expected = str![[r#"
<pre><code class="language-rust">mod test {
fn hello(arg: int) -&gt; bool {
true
}
}
</code></pre>
"#
];
snapbox::assert_eq(expected, output.unwrap());
"#]];

assert_data_eq!(output.unwrap(), expected.raw());
}

#[test]
Expand All @@ -354,17 +354,17 @@ mod test_raw {
&mut buf,
decorate_markdown(parser, syntax, Some("base16-ocean.dark")).unwrap(),
);
let expected = snapbox::str![
r#"<pre><code class="language-rust">mod test {
let expected = str![[r#"
<pre><code class="language-rust">mod test {
fn hello(arg: int) -&gt; bool {
true
}
}
</code></pre>
"#
];
snapbox::assert_eq(expected, buf);
"#]];

assert_data_eq!(&buf, expected.raw());
}
}

0 comments on commit 66dea35

Please sign in to comment.