Fix tests
All checks were successful
CI / lint (push) Successful in 2m21s
CI / Build and test (, 1.73.0) (push) Successful in 5m17s
CI / Build and test (, beta) (push) Successful in 5m40s
CI / Build and test (, nightly) (push) Successful in 5m7s

This commit is contained in:
2023-11-22 17:26:25 +01:00
parent 9cef34eb5c
commit 501ccc007e

View File

@ -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")),