mirror of
https://github.com/fdehau/tui-rs.git
synced 2024-11-18 21:26:33 +00:00
0ffea495b1
- merge `Style` and `StyleDiff` together. `Style` now is used to activate or deactivate certain style rules not to overidden all of them. - update all impacted widgets, examples and tests.
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use tui::{
|
|
backend::TestBackend,
|
|
buffer::Buffer,
|
|
layout::Rect,
|
|
style::{Color, Style},
|
|
text::Span,
|
|
widgets::{Block, Borders},
|
|
Terminal,
|
|
};
|
|
|
|
#[test]
|
|
fn widgets_block_renders() {
|
|
let backend = TestBackend::new(10, 10);
|
|
let mut terminal = Terminal::new(backend).unwrap();
|
|
terminal
|
|
.draw(|f| {
|
|
let block = Block::default()
|
|
.title(Span::styled("Title", Style::default().fg(Color::LightBlue)))
|
|
.borders(Borders::ALL);
|
|
f.render_widget(
|
|
block,
|
|
Rect {
|
|
x: 0,
|
|
y: 0,
|
|
width: 8,
|
|
height: 8,
|
|
},
|
|
);
|
|
})
|
|
.unwrap();
|
|
let mut expected = Buffer::with_lines(vec![
|
|
"┌Title─┐ ",
|
|
"│ │ ",
|
|
"│ │ ",
|
|
"│ │ ",
|
|
"│ │ ",
|
|
"│ │ ",
|
|
"│ │ ",
|
|
"└──────┘ ",
|
|
" ",
|
|
" ",
|
|
]);
|
|
for x in 1..=5 {
|
|
expected.get_mut(x, 0).set_fg(Color::LightBlue);
|
|
}
|
|
terminal.backend().assert_buffer(&expected);
|
|
}
|