Fix tests
This commit is contained in:
@ -14,14 +14,24 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use color_eyre::eyre::WrapErr;
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::prelude::*;
|
||||
|
||||
use ratatrix::buffers::{BufferItem, BufferItemContent};
|
||||
use ratatrix::components::Backlog;
|
||||
use ratatrix::config::Config;
|
||||
use ratatrix::widgets::Prerender;
|
||||
|
||||
fn config() -> Config {
|
||||
std::env::set_var("RATATRIX_CONFIG", PathBuf::from(".config/"));
|
||||
let c = Config::new();
|
||||
std::env::remove_var("RATATRIX_CONFIG");
|
||||
c.unwrap()
|
||||
}
|
||||
|
||||
fn rect(x: u16, y: u16, width: u16, height: u16) -> Rect {
|
||||
Rect {
|
||||
x,
|
||||
@ -50,7 +60,7 @@ macro_rules! items_iter {
|
||||
|
||||
#[test]
|
||||
fn test_single_item() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
@ -77,7 +87,7 @@ fn test_single_item() {
|
||||
|
||||
#[test]
|
||||
fn test_single_item_cached() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
@ -119,7 +129,7 @@ fn test_single_item_cached() {
|
||||
/// Checks that the prerender cache does not store empty columns to the right
|
||||
#[test]
|
||||
fn test_only_necessary_width() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let prerender2 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
@ -181,7 +191,7 @@ fn test_only_necessary_width() {
|
||||
|
||||
#[test]
|
||||
fn test_single_item_tight() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender = Prerender::new();
|
||||
let item = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hello")),
|
||||
@ -207,7 +217,7 @@ fn test_single_item_tight() {
|
||||
|
||||
#[test]
|
||||
fn test_two_items() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
@ -239,7 +249,7 @@ fn test_two_items() {
|
||||
|
||||
#[test]
|
||||
fn test_two_items_scroll() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let prerender2 = Prerender::new();
|
||||
|
||||
@ -328,7 +338,7 @@ fn test_two_items_scroll() {
|
||||
|
||||
#[test]
|
||||
fn test_two_items_multiline() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
@ -360,7 +370,7 @@ fn test_two_items_multiline() {
|
||||
|
||||
#[test]
|
||||
fn test_two_items_tight() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
@ -391,7 +401,7 @@ fn test_two_items_tight() {
|
||||
|
||||
#[test]
|
||||
fn test_cache_moved() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hi")),
|
||||
@ -445,7 +455,7 @@ fn test_cache_moved() {
|
||||
|
||||
#[test]
|
||||
fn test_overflow_and_scroll() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let prerender2 = Prerender::new();
|
||||
let prerender3 = Prerender::new();
|
||||
@ -594,7 +604,7 @@ fn test_overflow_and_scroll() {
|
||||
|
||||
#[test]
|
||||
fn test_scrolledup_new_line() {
|
||||
let mut bl = Backlog::default();
|
||||
let mut bl = Backlog::new(config());
|
||||
let prerender1 = Prerender::new();
|
||||
let item1 = BufferItem {
|
||||
content: BufferItemContent::Text(Text::raw("hi\nworld")),
|
||||
|
Reference in New Issue
Block a user