|
|
|
@ -743,7 +743,7 @@ mod test {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_calculate_cell_widths() {
|
|
|
|
|
fn test_calculate_cell_widths_when_sum_of_cell_widths_is_greater_than_table_width() {
|
|
|
|
|
let mut component = TableComponent::new(KeyConfig::default());
|
|
|
|
|
component.headers = vec!["1", "2", "3"].iter().map(|h| h.to_string()).collect();
|
|
|
|
|
component.rows = vec![
|
|
|
|
@ -766,6 +766,19 @@ mod test {
|
|
|
|
|
Constraint::Min(10),
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_calculate_cell_widths_when_sum_of_cell_widths_is_less_than_table_width() {
|
|
|
|
|
let mut component = TableComponent::new(KeyConfig::default());
|
|
|
|
|
component.headers = vec!["1", "2", "3"].iter().map(|h| h.to_string()).collect();
|
|
|
|
|
component.rows = vec![
|
|
|
|
|
vec!["aaaaa", "bbbbb", "ccccc"]
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|h| h.to_string())
|
|
|
|
|
.collect(),
|
|
|
|
|
vec!["d", "e", "f"].iter().map(|h| h.to_string()).collect(),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let (selected_column_index, headers, rows, constraints) =
|
|
|
|
|
component.calculate_cell_widths(20);
|
|
|
|
@ -784,10 +797,13 @@ mod test {
|
|
|
|
|
Constraint::Length(1),
|
|
|
|
|
Constraint::Length(5),
|
|
|
|
|
Constraint::Length(5),
|
|
|
|
|
Constraint::Min(10),
|
|
|
|
|
Constraint::Length(5),
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_calculate_cell_widths_when_component_has_multiple_rows() {
|
|
|
|
|
let mut component = TableComponent::new(KeyConfig::default());
|
|
|
|
|
component.headers = vec!["1", "2", "3"].iter().map(|h| h.to_string()).collect();
|
|
|
|
|
component.rows = vec![
|
|
|
|
@ -818,7 +834,7 @@ mod test {
|
|
|
|
|
Constraint::Length(1),
|
|
|
|
|
Constraint::Length(10),
|
|
|
|
|
Constraint::Length(5),
|
|
|
|
|
Constraint::Min(10),
|
|
|
|
|
Constraint::Length(5),
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|