Skip to content

Commit 47a2582

Browse files
jdxclaude
andcommitted
test: convert render tests to use insta inline snapshots
Benefits: - Easier to maintain: snapshots are stored inline with readable formatting - Clear diffs: changes to rendered output are immediately visible - Auto-update: cargo insta accept automatically updates snapshots - Better readability: raw strings preserve whitespace and special characters Changes: - Added insta = "1" as dev dependency - Converted test_render tests to use assert_snapshot! macro - Snapshots now stored inline with @r"..." syntax - Trailing spaces and formatting automatically captured 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 326eba6 commit 47a2582

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ termcolor = "1"
1919
[dev-dependencies]
2020
ctor = "0.6"
2121
indoc = "2"
22+
insta = "1"
2223

2324
[package.metadata.release]
2425
allow-branch = ["main"]

src/confirm.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ impl<'a> Confirm<'a> {
333333
mod tests {
334334
use super::*;
335335
use crate::test::without_ansi;
336+
use insta::assert_snapshot;
336337

337338
#[test]
338339
fn test_render() {
@@ -343,8 +344,14 @@ mod tests {
343344

344345
let rendered = confirm.render().unwrap();
345346
let actual = without_ansi(rendered.as_str());
346-
let expected = "Are you sure?\nThis will do a thing.\n\n Yes! No. \n\n←/→ toggle • y/n/enter submit\n";
347-
assert_eq!(expected, actual.as_ref());
347+
assert_snapshot!(actual.as_ref(), @r"
348+
Are you sure?
349+
This will do a thing.
350+
351+
Yes! No.
352+
353+
←/→ toggle • y/n/enter submit
354+
");
348355
}
349356

350357
#[test]
@@ -355,9 +362,14 @@ mod tests {
355362

356363
let rendered = confirm.render().unwrap();
357364
let actual = without_ansi(rendered.as_str());
358-
let expected =
359-
"Deploy to production?\n\n\n Confirm Cancel \n\n←/→ toggle • enter submit\n";
360-
assert_eq!(expected, actual.as_ref());
365+
assert_snapshot!(actual.as_ref(), @r"
366+
Deploy to production?
367+
368+
369+
Confirm Cancel
370+
371+
←/→ toggle • enter submit
372+
");
361373
}
362374

363375
#[test]
@@ -368,9 +380,14 @@ mod tests {
368380

369381
let rendered = confirm.render().unwrap();
370382
let actual = without_ansi(rendered.as_str());
371-
let expected =
372-
"Delete file?\n\n\n Proceed Abort \n\n←/→ toggle • p/a/enter submit\n";
373-
assert_eq!(expected, actual.as_ref());
383+
assert_snapshot!(actual.as_ref(), @r"
384+
Delete file?
385+
386+
387+
Proceed Abort
388+
389+
←/→ toggle • p/a/enter submit
390+
");
374391
}
375392

376393
#[test]

0 commit comments

Comments
 (0)