Skip to content

chore: Update to snapbox 0.6 #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading