Skip to content

Commit 492230c

Browse files
gallottinoOniryu95
andcommitted
Add tests for author.rs (#700)
Signed-off-by: gallottino <[email protected]> Co-authored-by: Oniryu95 <[email protected]>
1 parent cc7a59c commit 492230c

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

src/info/repo/author.rs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,97 @@ mod test {
135135

136136
assert_eq!(author.to_string(), "75% John Doe 1500");
137137
}
138+
139+
#[test]
140+
fn test_authors_info_title_with_one_author() {
141+
let author = Author::new(
142+
"John Doe".into(),
143+
144+
1500,
145+
2000,
146+
true,
147+
);
148+
149+
let authors_info = AuthorsInfo {
150+
info_color: DynColors::Rgb(255, 0, 0),
151+
authors: vec![author],
152+
};
153+
154+
assert_eq!(authors_info.title(), "Author");
155+
}
156+
157+
#[test]
158+
fn test_authors_info_title_with_two_authors() {
159+
let author = Author::new(
160+
"John Doe".into(),
161+
162+
1500,
163+
2000,
164+
true,
165+
);
166+
167+
let author_2 = Author::new(
168+
"Roberto Berto".into(),
169+
170+
240,
171+
300,
172+
false,
173+
);
174+
175+
let authors_info = AuthorsInfo {
176+
info_color: DynColors::Rgb(255, 0, 0),
177+
authors: vec![author, author_2],
178+
};
179+
180+
assert_eq!(authors_info.title(), "Authors");
181+
}
182+
183+
#[test]
184+
fn test_author_info_value_with_one_author() {
185+
let author = Author::new(
186+
"John Doe".into(),
187+
188+
1500,
189+
2000,
190+
true,
191+
);
192+
193+
let authors_info = AuthorsInfo {
194+
info_color: DynColors::Rgb(255, 0, 0),
195+
authors: vec![author],
196+
};
197+
198+
assert!(authors_info
199+
.value()
200+
.contains("75% John Doe <[email protected]> 1500"));
201+
}
202+
203+
#[test]
204+
fn test_author_info_value_with_two_authors() {
205+
let author = Author::new(
206+
"John Doe".into(),
207+
208+
1500,
209+
2000,
210+
true,
211+
);
212+
213+
let author_2 = Author::new(
214+
"Roberto Berto".into(),
215+
216+
240,
217+
300,
218+
false,
219+
);
220+
221+
let authors_info = AuthorsInfo {
222+
info_color: DynColors::Rgb(255, 0, 0),
223+
authors: vec![author, author_2],
224+
};
225+
226+
assert!(authors_info
227+
.value()
228+
.contains("75% John Doe <[email protected]> 1500"));
229+
assert!(authors_info.value().contains("80% Roberto Berto 240"));
230+
}
138231
}

0 commit comments

Comments
 (0)