Add tests for --theme > BAT_THEME > config

This commit is contained in:
Aaron Kollasch 2022-10-28 13:34:55 -04:00
parent e773b48135
commit bad2292950
No known key found for this signature in database
GPG Key ID: F813CAE853E39883
2 changed files with 59 additions and 0 deletions

1
tests/examples/bat-theme.conf vendored Normal file
View File

@ -0,0 +1 @@
--theme=TwoDark

View File

@ -1794,6 +1794,64 @@ fn no_wrapping_with_chop_long_lines() {
wrapping_test("--chop-long-lines", false);
}
#[test]
fn theme_arg_overrides_env() {
bat()
.env("BAT_THEME", "TwoDark")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--theme=ansi")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Ansi Underscore Test\nAnother Line")
.assert()
.success()
.stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line")
.stderr("");
}
#[test]
fn theme_arg_overrides_env_withconfig() {
bat_with_config()
.env("BAT_CONFIG_PATH", "bat-theme.conf")
.env("BAT_THEME", "TwoDark")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--theme=ansi")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Ansi Underscore Test\nAnother Line")
.assert()
.success()
.stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line")
.stderr("");
}
#[test]
fn theme_env_overrides_config() {
bat_with_config()
.env("BAT_CONFIG_PATH", "bat-theme.conf")
.env("BAT_THEME", "ansi")
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Ansi Underscore Test\nAnother Line")
.assert()
.success()
.stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line")
.stderr("");
}
#[test]
fn highlighting_is_skipped_on_long_lines() {
let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() +