Update tests
This commit is contained in:
@ -18,7 +18,7 @@ use color_eyre::eyre::WrapErr;
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::prelude::*;
|
||||
|
||||
use ratatrix::buffers::BufferItem;
|
||||
use ratatrix::buffers::{BufferItem, BufferItemContent};
|
||||
use ratatrix::components::Backlog;
|
||||
use ratatrix::widgets::Prerender;
|
||||
|
||||
@ -36,7 +36,7 @@ fn test_single_item() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
text: Text::raw("hello"),
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
prerender: &prerender,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 18, 8));
|
||||
@ -62,7 +62,7 @@ fn test_single_item_cached() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
text: Text::raw("hello"),
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
prerender: &prerender,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 18, 8));
|
||||
@ -86,7 +86,7 @@ fn test_single_item_cached() {
|
||||
assert_eq!(prerender.key(), Some(10));
|
||||
|
||||
let item = BufferItem {
|
||||
text: Text::raw("hello"),
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
prerender: &prerender,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 18, 8));
|
||||
@ -103,11 +103,11 @@ fn test_only_necessary_width() {
|
||||
let prerender1 = Prerender::new();
|
||||
let prerender2 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi\nworld"),
|
||||
content: BufferItemContent::Text(Text::raw("hi\nworld")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw(":)"),
|
||||
content: BufferItemContent::Text(Text::raw(":)")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut cell = ratatui::buffer::Cell::default();
|
||||
@ -132,11 +132,11 @@ fn test_only_necessary_width() {
|
||||
assert_eq!(prerender1.key(), Some(10));
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi\nworld"),
|
||||
content: BufferItemContent::Text(Text::raw("hi\nworld")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw(":)"),
|
||||
content: BufferItemContent::Text(Text::raw(":)")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 18, 7));
|
||||
@ -160,7 +160,7 @@ fn test_single_item_tight() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
text: Text::raw("hello"),
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
prerender: &prerender,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 13, 7));
|
||||
@ -185,12 +185,12 @@ fn test_two_items() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let prerender2 = Prerender::new();
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -217,11 +217,11 @@ fn test_two_items_scroll() {
|
||||
let prerender2 = Prerender::new();
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -243,11 +243,11 @@ fn test_two_items_scroll() {
|
||||
bl.scroll_up(1);
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -269,11 +269,11 @@ fn test_two_items_scroll() {
|
||||
bl.scroll_up(1);
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -298,12 +298,12 @@ fn test_two_items_multiline() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let prerender2 = Prerender::new();
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world\n!"),
|
||||
content: BufferItemContent::Text(Text::raw("world\n!")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -328,12 +328,12 @@ fn test_two_items_tight() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let prerender2 = Prerender::new();
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 9, 6));
|
||||
@ -357,7 +357,7 @@ fn test_cache_moved() {
|
||||
let mut bl = Backlog::default();
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
|
||||
@ -379,12 +379,12 @@ fn test_cache_moved() {
|
||||
|
||||
// New item added at bottom
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("hi"),
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let prerender2 = Prerender::new();
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("world"),
|
||||
content: BufferItemContent::Text(Text::raw("world")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -411,15 +411,15 @@ fn test_overflow_and_scroll() {
|
||||
let prerender3 = Prerender::new();
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("line1 x"),
|
||||
content: BufferItemContent::Text(Text::raw("line1 x")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("line2 y\nline3 y\nline4 y"),
|
||||
content: BufferItemContent::Text(Text::raw("line2 y\nline3 y\nline4 y")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let item3 = BufferItem {
|
||||
text: Text::raw("line5 z"),
|
||||
content: BufferItemContent::Text(Text::raw("line5 z")),
|
||||
prerender: &prerender3,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -444,15 +444,15 @@ fn test_overflow_and_scroll() {
|
||||
bl.scroll_up(1);
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("line1 x"),
|
||||
content: BufferItemContent::Text(Text::raw("line1 x")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("line2 y\nline3 y\nline4 y"),
|
||||
content: BufferItemContent::Text(Text::raw("line2 y\nline3 y\nline4 y")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let item3 = BufferItem {
|
||||
text: Text::raw("line5 z"),
|
||||
content: BufferItemContent::Text(Text::raw("line5 z")),
|
||||
prerender: &prerender3,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -477,15 +477,15 @@ fn test_overflow_and_scroll() {
|
||||
bl.scroll_up(1);
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("line1 x"),
|
||||
content: BufferItemContent::Text(Text::raw("line1 x")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("line2 y\nline3 y\nline4 y"),
|
||||
content: BufferItemContent::Text(Text::raw("line2 y\nline3 y\nline4 y")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let item3 = BufferItem {
|
||||
text: Text::raw("line5 z"),
|
||||
content: BufferItemContent::Text(Text::raw("line5 z")),
|
||||
prerender: &prerender3,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
@ -509,15 +509,15 @@ fn test_overflow_and_scroll() {
|
||||
bl.scroll_up(1);
|
||||
|
||||
let item1 = BufferItem {
|
||||
text: Text::raw("line1 x"),
|
||||
content: BufferItemContent::Text(Text::raw("line1 x")),
|
||||
prerender: &prerender1,
|
||||
};
|
||||
let item2 = BufferItem {
|
||||
text: Text::raw("line2 y\nline3 y\nline4 y"),
|
||||
content: BufferItemContent::Text(Text::raw("line2 y\nline3 y\nline4 y")),
|
||||
prerender: &prerender2,
|
||||
};
|
||||
let item3 = BufferItem {
|
||||
text: Text::raw("line5 z"),
|
||||
content: BufferItemContent::Text(Text::raw("line5 z")),
|
||||
prerender: &prerender3,
|
||||
};
|
||||
let mut buf = Buffer::empty(rect(0, 0, 14, 7));
|
||||
|
Reference in New Issue
Block a user