Improved coverage

This commit is contained in:
veeso
2021-04-05 09:59:10 +02:00
parent 9776ecbe60
commit 7676e6e3a1
11 changed files with 57 additions and 0 deletions

View File

@@ -303,6 +303,10 @@ mod tests {
assert_eq!(component.states.focus, true);
component.blur();
assert_eq!(component.states.focus, false);
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Increment list index
component.states.list_index += 1;
assert_eq!(component.states.list_index, 1);

View File

@@ -307,6 +307,10 @@ mod tests {
assert_eq!(component.states.focus, true);
component.blur();
assert_eq!(component.states.focus, false);
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Increment list index
component.states.list_index += 1;
assert_eq!(component.states.list_index, 1);

View File

@@ -342,6 +342,7 @@ mod tests {
use super::*;
use crossterm::event::KeyEvent;
use tui::style::Color;
#[test]
fn test_ui_layout_components_input_text() {
@@ -362,6 +363,10 @@ mod tests {
assert_eq!(component.states.focus, true);
component.blur();
assert_eq!(component.states.focus, false);
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::Text(String::from("home")));
// RenderData

View File

@@ -310,6 +310,7 @@ mod tests {
use crate::ui::layout::props::{TableBuilder, TextParts, TextSpan};
use crossterm::event::{KeyCode, KeyEvent};
use tui::style::Color;
#[test]
fn test_ui_layout_components_logbox() {
@@ -336,6 +337,10 @@ mod tests {
assert_eq!(component.states.focus, true);
component.blur();
assert_eq!(component.states.focus, false);
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Increment list index
component.states.list_index += 1;
assert_eq!(component.states.list_index, 1);

View File

@@ -197,6 +197,12 @@ mod tests {
))
.build(),
);
component.active();
component.blur();
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::None);
// Event

View File

@@ -155,6 +155,7 @@ mod tests {
use crate::ui::layout::props::{TextParts, TextSpan};
use crossterm::event::{KeyCode, KeyEvent};
use tui::style::Color;
#[test]
fn test_ui_layout_components_progress_bar() {
@@ -168,6 +169,12 @@ mod tests {
);
// Get value
assert_eq!(component.get_value(), Payload::None);
component.active();
component.blur();
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Event
assert_eq!(
component.on(InputEvent::Key(KeyEvent::from(KeyCode::Delete))),

View File

@@ -284,6 +284,10 @@ mod tests {
assert_eq!(component.states.focus, true);
component.blur();
assert_eq!(component.states.focus, false);
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::Unsigned(1));
// Handle events

View File

@@ -167,6 +167,7 @@ mod tests {
use crate::ui::layout::props::{TableBuilder, TextParts, TextSpan};
use crossterm::event::{KeyCode, KeyEvent};
use tui::style::Color;
#[test]
fn test_ui_layout_components_table() {
@@ -184,6 +185,12 @@ mod tests {
))
.build(),
);
component.active();
component.blur();
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::None);
// Event

View File

@@ -178,6 +178,12 @@ mod tests {
))
.build(),
);
component.active();
component.blur();
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::None);
// Event

View File

@@ -133,6 +133,7 @@ mod tests {
use crate::ui::layout::props::TextParts;
use crossterm::event::{KeyCode, KeyEvent};
use tui::style::Color;
#[test]
fn test_ui_layout_components_title() {
@@ -141,6 +142,12 @@ mod tests {
.with_texts(TextParts::new(Some(String::from("Title")), None))
.build(),
);
component.active();
component.blur();
// Update
let props = component.get_props().with_foreground(Color::Red).build();
assert_eq!(component.update(props), Msg::None);
assert_eq!(component.props.foreground, Color::Red);
// Get value
assert_eq!(component.get_value(), Payload::None);
// Event