lotabout.skim/e2e/tests/case.rs
LoricAndre 7f0dec4b48
test: migrate e2e to rust (#629)
* wip: enhance release ci

* update PR checklist

* wip: rewrite e2e in rust

* add e2e cargo module

* rewrite all e2e tests in rust

* remove python tests

* clippy & fmt

* use cargo tests in ci

* use which to get tmux

* check len

* check all lens

* increase time out and parallelism

* fix no hscroll typo

* better check for print0

* add sleep

* fix execute_0

* update release ci

* try optimizing tests

* better sleep

* Revert "better sleep"

This reverts commit b966367999.

* split ci

* cleanup

* test without anchor

* use release-please

---------

Co-authored-by: LoricAndre <loric.andre@pm.me>
2024-11-30 20:29:14 +01:00

84 lines
2.1 KiB
Rust

use e2e::Keys::*;
use e2e::TmuxController;
use std::io::Result;
fn setup(case: &str) -> Result<TmuxController> {
let tmux = TmuxController::new()?;
let _ = tmux.start_sk(Some(&format!("echo -n -e 'aBcDeF'")), &["--case", case])?;
tmux.until(|l| l[0].starts_with(">"))?;
Ok(tmux)
}
#[test]
fn case_smart_lower() -> Result<()> {
let tmux = setup("smart")?;
tmux.send_keys(&[Str("abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_smart_exact() -> Result<()> {
let tmux = setup("smart")?;
tmux.send_keys(&[Str("aBc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_smart_no_match() -> Result<()> {
let tmux = setup("smart")?;
tmux.send_keys(&[Str("Abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))
}
#[test]
fn case_ignore_lower() -> Result<()> {
let tmux = setup("ignore")?;
tmux.send_keys(&[Str("abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_ignore_exact() -> Result<()> {
let tmux = setup("ignore")?;
tmux.send_keys(&[Str("aBc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_ignore_different() -> Result<()> {
let tmux = setup("ignore")?;
tmux.send_keys(&[Str("Abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_ignore_no_match() -> Result<()> {
let tmux = setup("ignore")?;
tmux.send_keys(&[Str("z")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))
}
#[test]
fn case_respect_lower() -> Result<()> {
let tmux = setup("respect")?;
tmux.send_keys(&[Str("abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))
}
#[test]
fn case_respect_exact() -> Result<()> {
let tmux = setup("respect")?;
tmux.send_keys(&[Str("aBc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))
}
#[test]
fn case_respect_no_match() -> Result<()> {
let tmux = setup("respect")?;
tmux.send_keys(&[Str("Abc")])?;
tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))
}