Add integration tests for merging styles

A huge thanks to @einfachIrgendwer0815 for helping me make sure
these tests work under the MSRV CI job.
This commit is contained in:
Ethan P. 2024-04-06 17:21:03 -07:00
parent 93b25d75a0
commit 180a77ee99
No known key found for this signature in database
GPG Key ID: B29B90B1B228FEBC

View File

@ -2810,3 +2810,71 @@ fn strip_ansi_auto_does_not_strip_ansi_when_plain_text_by_option() {
assert!(output.contains("\x1B[33mYellow"))
}
// Tests that style components can be removed with `-component`.
#[test]
fn style_components_can_be_removed() {
bat()
.arg({
#[cfg(not(feature = "git"))]
{
"--style=full,-grid"
}
#[cfg(feature = "git")]
{
"--style=full,-grid,-changes"
}
})
.arg("--decorations=always")
.arg("--color=never")
.write_stdin("test")
.assert()
.success()
.stdout(" STDIN\n Size: -\n 1 test\n")
.stderr("");
}
// Tests that style components are chosen based on the rightmost `--style` argument.
#[test]
fn style_components_can_be_overidden() {
bat()
.arg("--style=full")
.arg("--style=header,numbers")
.arg("--decorations=always")
.arg("--color=never")
.write_stdin("test")
.assert()
.success()
.stdout(" STDIN\n 1 test\n")
.stderr("");
}
// Tests that style components can be merged across multiple `--style` arguments.
#[test]
fn style_components_will_merge() {
bat()
.arg("--style=header,grid")
.arg("--style=-grid,+numbers")
.arg("--decorations=always")
.arg("--color=never")
.write_stdin("test")
.assert()
.success()
.stdout(" STDIN\n 1 test\n")
.stderr("");
}
// Tests that style components can be merged with the `BAT_STYLE` environment variable.
#[test]
fn style_components_will_merge_with_env_var() {
bat()
.env("BAT_STYLE", "header,grid")
.arg("--style=-grid,+numbers")
.arg("--decorations=always")
.arg("--color=never")
.write_stdin("test")
.assert()
.success()
.stdout(" STDIN\n 1 test\n")
.stderr("");
}