Added unit tests for all the new widgets

This commit is contained in:
2024-02-13 12:03:56 -07:00
parent 6ba78cb4ba
commit 649f4b5e3b
16 changed files with 611 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
#[cfg(test)]
mod tests {
use crate::ui::widgets::button::Button;
use pretty_assertions::{assert_eq, assert_str_eq};
use ratatui::style::{Style, Stylize};
#[test]
fn test_title() {
let button = Button::default().title("Title");
assert_str_eq!(button.title, "Title");
}
#[test]
fn test_label() {
let button = Button::default().label("Label");
assert_eq!(button.label, Some("Label"));
}
#[test]
fn test_icon() {
let button = Button::default().icon("Icon");
assert_eq!(button.icon, Some("Icon"));
}
#[test]
fn test_style() {
let button = Button::default().style(Style::new().bold());
assert_eq!(button.style, Style::new().bold());
}
#[test]
fn test_selected() {
let button = Button::default().selected(true);
assert!(button.is_selected);
}
}