forked from o2sh/onefetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert author tests to snapshot tests
- Loading branch information
1 parent
b1cf029
commit 7936878
Showing
4 changed files
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ impl InfoField for AuthorsInfo { | |
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use insta::assert_snapshot; | ||
|
||
#[test] | ||
fn test_display_author() { | ||
|
@@ -189,6 +190,7 @@ mod test { | |
assert_eq!(authors_info.title(), "Authors"); | ||
} | ||
|
||
// TODO Move these snapshot tests to a more appropriate module so that the title and value are tested together | ||
#[test] | ||
fn test_author_info_value_with_one_author() { | ||
let author = Author::new( | ||
|
@@ -203,10 +205,7 @@ mod test { | |
authors: vec![author], | ||
}; | ||
|
||
assert_eq!( | ||
authors_info.value(), | ||
"75% John Doe <[email protected]> 1500".to_string() | ||
); | ||
assert_snapshot!(authors_info.value()); | ||
} | ||
|
||
#[test] | ||
|
@@ -235,9 +234,7 @@ mod test { | |
.value() | ||
.contains(&"75% John Doe <[email protected]> 1500".to_string())); | ||
|
||
assert!(authors_info | ||
.value() | ||
.contains(&"80% Roberto Berto 240".to_string())); | ||
assert_snapshot!(authors_info.value()); | ||
} | ||
#[test] | ||
fn test_author_info_value_alignment_with_three_authors() { | ||
|
@@ -263,15 +260,6 @@ mod test { | |
authors: vec![author, author_2, author_3], | ||
}; | ||
|
||
assert!(authors_info | ||
.value() | ||
.contains(&"75% John Doe <[email protected]> 1500".to_string())); | ||
|
||
assert!(authors_info | ||
.value() | ||
.contains(&"80% Roberto Berto 240".to_string())); | ||
|
||
// Note the extra leading space to right-align the percentages | ||
assert!(authors_info.value().contains(&" 1% Jane Doe 1".to_string())); | ||
assert_snapshot!(authors_info.value()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...apshots/onefetch__info__author__test__author_info_value_alignment_with_three_authors.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
source: src/info/author.rs | ||
expression: authors_info.value() | ||
--- | ||
75% John Doe <[email protected]> 1500 | ||
80% Roberto Berto 240 | ||
1% Jane Doe 1 |
5 changes: 5 additions & 0 deletions
5
src/info/snapshots/onefetch__info__author__test__author_info_value_with_one_author.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: src/info/author.rs | ||
expression: authors_info.value() | ||
--- | ||
75% John Doe <[email protected]> 1500 |
6 changes: 6 additions & 0 deletions
6
src/info/snapshots/onefetch__info__author__test__author_info_value_with_two_authors.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
source: src/info/author.rs | ||
expression: authors_info.value() | ||
--- | ||
75% John Doe <[email protected]> 1500 | ||
80% Roberto Berto 240 |