Add test for auto-cd
This commit is contained in:
parent
9f5995e21f
commit
e97aa2af0e
|
@ -5,6 +5,38 @@ use nu_test_support::terminal::{
|
||||||
};
|
};
|
||||||
use std::{io::Write, time::Duration};
|
use std::{io::Write, time::Duration};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn auto_cd_works() {
|
||||||
|
// Setup a directory with a sub-directory in it.
|
||||||
|
let cwd = tempfile::tempdir().unwrap();
|
||||||
|
std::fs::create_dir(cwd.path().join("foo")).unwrap();
|
||||||
|
|
||||||
|
// Create the PTY and the terminal.
|
||||||
|
let mut pty = pty_with_nushell(
|
||||||
|
vec!["--no-config-file".to_string()],
|
||||||
|
Some(cwd.path().to_path_buf()),
|
||||||
|
);
|
||||||
|
let (mut term, mut events) = default_terminal();
|
||||||
|
|
||||||
|
// Wait for Nushell to initalize.
|
||||||
|
std::thread::sleep(Duration::from_millis(500));
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pty.writer().write_all(b".\\foo\r").unwrap();
|
||||||
|
#[cfg(unix)]
|
||||||
|
pty.writer().write_all(b"./foo\r").unwrap();
|
||||||
|
|
||||||
|
pty.writer().write_all(b"pwd\r").unwrap();
|
||||||
|
|
||||||
|
// Read the response from Nushell.
|
||||||
|
read_to_end(&mut term, &mut pty, &mut events, pty_write_handler);
|
||||||
|
|
||||||
|
// Examine the terminal state.
|
||||||
|
let (row, _col) = extract_cursor(&term);
|
||||||
|
let text = extract_text(&term);
|
||||||
|
assert!(text[row - 1].contains("foo"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command_hints_are_pwd_aware() {
|
fn command_hints_are_pwd_aware() {
|
||||||
// PWD-aware command hints require setting history file format to "sqlite".
|
// PWD-aware command hints require setting history file format to "sqlite".
|
||||||
|
|
Loading…
Reference in New Issue
Block a user