Lines
100 %
Functions
Branches
//! A kitty chart in a window hanging off an edge: shown while its transmit cell is on screen.
use super::report_chart::{env, rendered, text};
use super::window_keys::{answer_chart, drawn_kitty_chart};
use crate::app::App;
use crate::test_support::{key, press};
use ratatui::crossterm::event::KeyCode;
use rpc::chart::ChartBackend;
use tvui::{Place, Window};
async fn unzoomed_chart() -> (App, u32) {
let (mut app, image) = drawn_kitty_chart();
press(&mut app, key(KeyCode::F(5)));
answer_chart(&mut app);
app.take_outbound();
(app, image)
}
fn move_front_to(app: &mut App, x: i32) {
let id = app.front_window().expect("a front window");
let window = app.desktop.window(id).expect("it is open");
let place = Place { x, ..window.place };
app.desktop.restore(Window { place, ..window });
#[tokio::test]
async fn a_chart_off_the_right_edge_keeps_its_image_while_the_corner_shows() {
let (mut app, _) = unzoomed_chart().await;
move_front_to(&mut app, 20);
assert!(text(&rendered(&app, 40, 20)).contains("a=T"));
async fn a_chart_off_the_left_edge_hides_its_image_with_the_corner() {
move_front_to(&mut app, -10);
assert!(!text(&rendered(&app, 40, 20)).contains("a=T"));
async fn a_resize_deletes_the_image_whose_corner_is_off_screen_and_only_that() {
let (mut app, image) = unzoomed_chart().await;
app.sync_terminal(env(40, 22, ChartBackend::Kitty));
assert!(app.take_outbound().is_empty());
app.sync_terminal(env(40, 20, ChartBackend::Kitty));
assert_eq!(app.take_outbound(), vec![tvui::kitty_delete(image)]);