diff --git a/tests/size.rs b/tests/terminal.rs similarity index 67% rename from tests/size.rs rename to tests/terminal.rs index a5055ff7..67305e05 100644 --- a/tests/size.rs +++ b/tests/terminal.rs @@ -1,8 +1,10 @@ -use tui::backend::{Backend, TestBackend}; -use tui::Terminal; +use tui::{ + backend::{Backend, TestBackend}, + Terminal, +}; #[test] -fn buffer_size_limited() { +fn terminal_buffer_size_should_be_limited() { let backend = TestBackend::new(400, 400); let terminal = Terminal::new(backend).unwrap(); let size = terminal.backend().size().unwrap(); diff --git a/tests/widgets_block.rs b/tests/widgets_block.rs index 27f1554f..a19c6d37 100644 --- a/tests/widgets_block.rs +++ b/tests/widgets_block.rs @@ -6,7 +6,7 @@ use tui::widgets::{Block, Borders}; use tui::Terminal; #[test] -fn it_draws_a_block() { +fn widgets_block_renders() { let backend = TestBackend::new(10, 10); let mut terminal = Terminal::new(backend).unwrap(); terminal diff --git a/tests/widgets_chart.rs b/tests/widgets_chart.rs index 53c8446c..c8513591 100644 --- a/tests/widgets_chart.rs +++ b/tests/widgets_chart.rs @@ -8,7 +8,7 @@ use tui::{ }; #[test] -fn zero_axes_ok() { +fn widgets_chart_can_have_axis_with_zero_length_bounds() { let backend = TestBackend::new(100, 100); let mut terminal = Terminal::new(backend).unwrap(); @@ -37,7 +37,7 @@ fn zero_axes_ok() { } #[test] -fn handles_overflow() { +fn widgets_chart_handles_overflows() { let backend = TestBackend::new(80, 30); let mut terminal = Terminal::new(backend).unwrap(); @@ -74,7 +74,7 @@ fn handles_overflow() { } #[test] -fn empty_dataset_line_test() { +fn widgets_chart_can_have_empty_datasets() { let backend = TestBackend::new(100, 100); let mut terminal = Terminal::new(backend).unwrap(); diff --git a/tests/widgets_gauge.rs b/tests/widgets_gauge.rs index 25b8607f..681e4db8 100644 --- a/tests/widgets_gauge.rs +++ b/tests/widgets_gauge.rs @@ -7,7 +7,7 @@ use tui::{ }; #[test] -fn gauge_render() { +fn widgets_gauge_renders() { let backend = TestBackend::new(40, 10); let mut terminal = Terminal::new(backend).unwrap(); terminal diff --git a/tests/widgets_list.rs b/tests/widgets_list.rs index 98309f74..3a2479b8 100644 --- a/tests/widgets_list.rs +++ b/tests/widgets_list.rs @@ -9,7 +9,7 @@ use tui::{ }; #[test] -fn it_should_highlight_the_selected_item() { +fn widgets_list_should_highlight_the_selected_item() { let backend = TestBackend::new(10, 3); let mut terminal = Terminal::new(backend).unwrap(); let mut state = ListState::default(); @@ -32,24 +32,23 @@ fn it_should_highlight_the_selected_item() { for x in 0..9 { expected.get_mut(x, 1).set_bg(Color::Yellow); } - assert_eq!(*terminal.backend().buffer(), expected); + terminal.backend().assert_buffer(&expected); } #[test] -fn it_should_truncate_items() { +fn widgets_list_should_truncate_items() { let backend = TestBackend::new(10, 2); let mut terminal = Terminal::new(backend).unwrap(); struct TruncateTestCase<'a> { - name: &'a str, selected: Option, items: Vec>, expected: Buffer, } let cases = vec![ + // An item is selected TruncateTestCase { - name: "an item is selected", selected: Some(0), items: vec![Text::raw("A very long line"), Text::raw("A very long line")], expected: Buffer::with_lines(vec![ @@ -57,8 +56,8 @@ fn it_should_truncate_items() { format!(" A ve{} ", symbols::line::VERTICAL), ]), }, + // No item is selected TruncateTestCase { - name: "no item is selected", selected: None, items: vec![Text::raw("A very long line"), Text::raw("A very long line")], expected: Buffer::with_lines(vec![ @@ -79,11 +78,6 @@ fn it_should_truncate_items() { f.render_stateful_widget(list, Rect::new(0, 0, 8, 2), &mut state); }) .unwrap(); - assert_eq!( - *terminal.backend().buffer(), - case.expected, - "Failed to assert the buffer matches the expected one when {}", - case.name - ); + terminal.backend().assert_buffer(&case.expected); } } diff --git a/tests/widgets_paragraph.rs b/tests/widgets_paragraph.rs index 59726b0c..d3cd5489 100644 --- a/tests/widgets_paragraph.rs +++ b/tests/widgets_paragraph.rs @@ -12,7 +12,7 @@ const SAMPLE_STRING: &str = "The library is based on the principle of immediate interactive UI, this may introduce overhead for highly dynamic content."; #[test] -fn paragraph_render_wrap() { +fn widgets_paragraph_can_wrap_its_content() { let test_case = |alignment, expected| { let backend = TestBackend::new(20, 10); let mut terminal = Terminal::new(backend).unwrap(); @@ -79,7 +79,7 @@ fn paragraph_render_wrap() { } #[test] -fn paragraph_render_double_width() { +fn widgets_paragraph_renders_double_width_graphemes() { let backend = TestBackend::new(10, 10); let mut terminal = Terminal::new(backend).unwrap(); @@ -111,7 +111,7 @@ fn paragraph_render_double_width() { } #[test] -fn paragraph_render_mixed_width() { +fn widgets_paragraph_renders_mixed_width_graphemes() { let backend = TestBackend::new(10, 7); let mut terminal = Terminal::new(backend).unwrap(); diff --git a/tests/widgets_table.rs b/tests/widgets_table.rs index add7aa0a..c606a54a 100644 --- a/tests/widgets_table.rs +++ b/tests/widgets_table.rs @@ -5,7 +5,7 @@ use tui::widgets::{Block, Borders, Row, Table}; use tui::Terminal; #[test] -fn table_column_spacing() { +fn widgets_table_column_spacing_can_be_changed() { let test_case = |column_spacing, expected| { let backend = TestBackend::new(30, 10); let mut terminal = Terminal::new(backend).unwrap(); @@ -106,7 +106,7 @@ fn table_column_spacing() { } #[test] -fn table_widths() { +fn widgets_table_columns_widths_can_use_fixed_length_constraints() { let test_case = |widths, expected| { let backend = TestBackend::new(30, 10); let mut terminal = Terminal::new(backend).unwrap(); @@ -197,7 +197,7 @@ fn table_widths() { } #[test] -fn table_percentage_widths() { +fn widgets_table_columns_widths_can_use_percentage_constraints() { let test_case = |widths, expected| { let backend = TestBackend::new(30, 10); let mut terminal = Terminal::new(backend).unwrap(); @@ -306,7 +306,7 @@ fn table_percentage_widths() { } #[test] -fn table_mixed_widths() { +fn widgets_table_columns_widths_can_use_mixed_constraints() { let test_case = |widths, expected| { let backend = TestBackend::new(30, 10); let mut terminal = Terminal::new(backend).unwrap(); diff --git a/tests/widgets_tabs.rs b/tests/widgets_tabs.rs index 87ef8a2e..58e40bd6 100644 --- a/tests/widgets_tabs.rs +++ b/tests/widgets_tabs.rs @@ -1,7 +1,7 @@ use tui::{backend::TestBackend, buffer::Buffer, layout::Rect, symbols, widgets::Tabs, Terminal}; #[test] -fn tabs_should_not_panic_on_narrow_areas() { +fn widgets_tabs_should_not_panic_on_narrow_areas() { let backend = TestBackend::new(1, 1); let mut terminal = Terminal::new(backend).unwrap(); terminal @@ -23,7 +23,7 @@ fn tabs_should_not_panic_on_narrow_areas() { } #[test] -fn tabs_should_truncate_the_last_item() { +fn widgets_tabs_should_truncate_the_last_item() { let backend = TestBackend::new(10, 1); let mut terminal = Terminal::new(backend).unwrap(); terminal