Skip to content

Commit

Permalink
Fix tests I broke for list row management
Browse files Browse the repository at this point in the history
Fix tests I broke for list row management so that we are in a good state
again.

<!-- ps-id: 20431b79-96e0-41f5-a421-ca22f73ff4da -->
  • Loading branch information
drewdeponte committed Oct 19, 2023
1 parent d98445f commit 9261a98
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions src/ps/private/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ mod tests {
let cell = ListCell {
width: Some(4),
color: Some(Blue),
bg_color: None,
value: "hello".to_string(),
};
assert_eq!(format!("{}", cell), "\u{1b}[34mhell\u{1b}[0m");
Expand All @@ -126,6 +127,7 @@ mod tests {
let cell = ListCell {
width: Some(6),
color: None,
bg_color: None,
value: "hello".to_string(),
};
assert_eq!(format!("{}", cell), "hello ");
Expand All @@ -136,6 +138,7 @@ mod tests {
let cell = ListCell {
width: None,
color: None,
bg_color: None,
value: "hello".to_string(),
};
assert_eq!(format!("{}", cell), "hello");
Expand All @@ -157,14 +160,15 @@ mod tests {
fn test_list_row_add_cell() {
let mut row = ListRow::new(false);
let cell_value = "hello".to_string();
row.add_cell(None, None, &cell_value);
row.add_cell(None, None, None, &cell_value);
assert_eq!(
row,
ListRow {
with_color: false,
cells: vec![ListCell {
width: None,
color: None,
bg_color: None,
value: cell_value
}]
}
Expand All @@ -177,16 +181,28 @@ mod tests {
let first_cell = ListCell {
width: Some(10),
color: Some(Blue),
bg_color: None,
value: "Hello".to_string(),
};
let second_cell = ListCell {
width: None,
color: None,
bg_color: None,
value: "World".to_string(),
};
row.add_cell(first_cell.width, first_cell.color, first_cell.value);
row.add_cell(second_cell.width, second_cell.color, second_cell.value);
assert_eq!(format!("{}", row), "\u{1b}[34mHello \u{1b}[0m World ")
row.add_cell(
first_cell.width,
first_cell.color,
first_cell.bg_color,
first_cell.value,
);
row.add_cell(
second_cell.width,
second_cell.color,
second_cell.bg_color,
second_cell.value,
);
assert_eq!(format!("{}", row), "\u{1b}[34mHello \u{1b}[0mWorld")
}

#[test]
Expand All @@ -195,15 +211,27 @@ mod tests {
let first_cell = ListCell {
width: Some(10),
color: Some(Blue),
bg_color: None,
value: "Hello".to_string(),
};
let second_cell = ListCell {
width: None,
color: None,
bg_color: None,
value: "World".to_string(),
};
row.add_cell(first_cell.width, first_cell.color, first_cell.value);
row.add_cell(second_cell.width, second_cell.color, second_cell.value);
assert_eq!(format!("{}", row), "Hello World ")
row.add_cell(
first_cell.width,
first_cell.color,
first_cell.bg_color,
first_cell.value,
);
row.add_cell(
second_cell.width,
second_cell.color,
second_cell.bg_color,
second_cell.value,
);
assert_eq!(format!("{}", row), "Hello World")
}
}

0 comments on commit 9261a98

Please sign in to comment.