You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently an example for how to write tests is only shown in the tutorial. It would be nice to have it as a separate page to make it easier for search engines to find it. It'll also be easier to read for users who are interested in just that one aspect of Ratatui
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render() {
let app = App::default();
let mut buf = Buffer::empty(Rect::new(0, 0, 50, 4));
app.render(buf.area, &mut buf);
let mut expected = Buffer::with_lines(vec![
"┏━━━━━━━━━━━━━ Counter App Tutorial ━━━━━━━━━━━━━┓",
"┃ Value: 0 ┃",
"┃ ┃",
"┗━ Decrement <Left> Increment <Right> Quit <Q> ━━┛",
]);
let title_style = Style::new().bold();
let counter_style = Style::new().yellow();
let key_style = Style::new().blue().bold();
expected.set_style(Rect::new(14, 0, 22, 1), title_style);
expected.set_style(Rect::new(28, 1, 1, 1), counter_style);
expected.set_style(Rect::new(13, 3, 6, 1), key_style);
expected.set_style(Rect::new(30, 3, 7, 1), key_style);
expected.set_style(Rect::new(43, 3, 4, 1), key_style);
// note ratatui also has an assert_buffer_eq! macro that can be used to
// compare buffers and display the differences in a more readable way
assert_eq!(buf, expected);
}
}
The text was updated successfully, but these errors were encountered:
kdheepak
changed the title
Add separate page on how to set UI
Add separate page on how to test UI
May 2, 2024
Currently an example for how to write tests is only shown in the tutorial. It would be nice to have it as a separate page to make it easier for search engines to find it. It'll also be easier to read for users who are interested in just that one aspect of Ratatui
The text was updated successfully, but these errors were encountered: