2023-09-01 00:08:27 +02:00
|
|
|
use nu_test_support::nu;
|
2023-06-16 18:40:03 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_ansi_shows_error_on_escape() {
|
2023-10-19 22:04:33 +02:00
|
|
|
let actual = nu!(r"ansi --escape \");
|
2023-06-16 18:40:03 +02:00
|
|
|
|
|
|
|
assert!(actual.err.contains("no need for escape characters"))
|
|
|
|
}
|
2023-07-26 23:39:24 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_ansi_list_outputs_table() {
|
2023-09-01 00:08:27 +02:00
|
|
|
let actual = nu!("ansi --list | length");
|
2023-07-26 23:39:24 +02:00
|
|
|
|
2024-10-29 13:01:32 +01:00
|
|
|
assert_eq!(actual.out, "425");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_ansi_codes() {
|
|
|
|
let actual = nu!("$'(ansi clear_scrollback_buffer)'");
|
|
|
|
assert_eq!(actual.out, "\x1b[3J");
|
|
|
|
|
|
|
|
// Currently, bg is placed before fg in the results
|
|
|
|
// It's okay if something internally changes this, but
|
|
|
|
// if so, the test case will need to be updated to:
|
|
|
|
// assert_eq!(actual.out, "\x1b[31;48;2;0;255;0mHello\x1b[0m");
|
|
|
|
|
|
|
|
let actual = nu!("$'(ansi { fg: red, bg: \"#00ff00\" })Hello(ansi reset)'");
|
|
|
|
assert_eq!(actual.out, "\x1b[48;2;0;255;0;31mHello\x1b[0m");
|
2023-07-26 23:39:24 +02:00
|
|
|
}
|