Skip to content

Commit

Permalink
Add tests for author.rs (o2sh#700)
Browse files Browse the repository at this point in the history
Signed-off-by: gallottino <[email protected]>
Co-authored-by: Oniryu95  <[email protected]>
  • Loading branch information
gallottino and Oniryu95 committed Oct 18, 2022
1 parent cc7a59c commit 7866c28
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions src/info/repo/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,97 @@ mod test {

assert_eq!(author.to_string(), "75% John Doe 1500");
}

#[test]
fn test_authors_info_title_with_one_author() {
let author = Author::new(
"John Doe".into(),
"[email protected]".into(),
1500,
2000,
true,
);

let authors_info = AuthorsInfo {
info_color: DynColors::Rgb(255, 0, 0),
authors: vec![author],
};

assert_eq!(authors_info.title(), "Author");
}

#[test]
fn test_authors_info_title_with_two_authors() {
let author = Author::new(
"John Doe".into(),
"[email protected]".into(),
1500,
2000,
true,
);

let author_2 = Author::new(
"Roberto Berto".into(),
"[email protected]".into(),
240,
300,
false,
);

let authors_info = AuthorsInfo {
info_color: DynColors::Rgb(255, 0, 0),
authors: vec![author, author_2],
};

assert_eq!(authors_info.title(), "Authors");
}

#[test]
fn test_author_info_value_with_one_author() {
let author = Author::new(
"John Doe".into(),
"[email protected]".into(),
1500,
2000,
true,
);

let authors_info = AuthorsInfo {
info_color: DynColors::Rgb(255, 0, 0),
authors: vec![author.clone()],
};

assert!(authors_info
.value()
.contains("75% John Doe <[email protected]> 1500"));
}

#[test]
fn test_author_info_value_with_two_author() {
let author = Author::new(
"John Doe".into(),
"[email protected]".into(),
1500,
2000,
true,
);

let author_2 = Author::new(
"Roberto Berto".into(),
"[email protected]".into(),
240,
300,
false,
);

let authors_info = AuthorsInfo {
info_color: DynColors::Rgb(255, 0, 0),
authors: vec![author, author_2],
};

assert!(authors_info
.value()
.contains("75% John Doe <[email protected]> 1500"));
assert!(authors_info.value().contains("80% Roberto Berto 240"));
}
}

0 comments on commit 7866c28

Please sign in to comment.