Skip to content

Commit

Permalink
test(term): add test case that resize terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Jun 13, 2024
1 parent ebafc73 commit 05251ee
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
32 changes: 31 additions & 1 deletion crates/synd_term/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod test {
use synd_test::temp_dir;

mod helper;
use crate::test::helper::TestCase;
use crate::test::helper::{resize_event, TestCase};

#[tokio::test(flavor = "multi_thread")]
async fn login_with_github() -> anyhow::Result<()> {
Expand Down Expand Up @@ -336,6 +336,36 @@ mod test {
Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn resize_terminal_to_zero() -> anyhow::Result<()> {
let (mut col, mut row) = (120, 30);
let test_case = TestCase {
mock_port: 6050,
synd_api_port: 6051,
kvsd_port: 6052,
terminal_col_row: (col, row),
..Default::default()
}
.already_logined();

let mut application = test_case.init_app().await?;
let (tx, mut event_stream) = helper::event_stream();

loop {
col /= 2;
row /= 2;
if col == 0 && row == 0 {
break;
}
// Assert that app do not panic
tx.send(resize_event(col, row));
application
.wait_until_jobs_completed(&mut event_stream)
.await;
}
Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn cli_commands() -> anyhow::Result<()> {
let test_case = TestCase {
Expand Down
4 changes: 4 additions & 0 deletions crates/synd_term/tests/test/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,7 @@ impl UnboundedSenderWrapper {
});
}
}

pub fn resize_event(columns: u16, rows: u16) -> crossterm::event::Event {
crossterm::event::Event::Resize(columns, rows)
}

0 comments on commit 05251ee

Please sign in to comment.