1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-10-11 06:13:53 +01:00

add integration test for ANSI theme with simple JSON

This commit is contained in:
Keith Hall
2025-10-08 23:12:08 +03:00
parent 3e816f08c7
commit c0389b0e5c

View File

@@ -2404,6 +2404,24 @@ fn ansi_highlight_underline() {
.stderr("");
}
// we don't really test other color schemes in the syntax-tests/source vs highlighted stuff
// so here a simple integration test has been made for the ANSI theme,
// which lives directly inside the bat repository
#[test]
fn ansi_highlight_json_keys() {
bat()
.arg("--paging=never")
.arg("--color=always")
.arg("--decorations=never")
.arg("--theme=ansi")
.arg("--language=json")
.write_stdin("{\"foo\": \"bar\", \"test\": [123, \"baz\"] }")
.assert()
.success()
.stdout("{\x1B[34m\"\x1B[0m\x1B[34mfoo\x1B[0m\x1B[34m\"\x1B[0m: \x1B[32m\"\x1B[0m\x1B[32mbar\x1B[0m\x1B[32m\"\x1B[0m, \x1B[34m\"\x1B[0m\x1B[34mtest\x1B[0m\x1B[34m\"\x1B[0m: [\x1B[33m123\x1B[0m, \x1B[32m\"\x1B[0m\x1B[32mbaz\x1B[0m\x1B[32m\"\x1B[0m] }")
.stderr("");
}
// Ensure that ANSI passthrough is emitted properly for both wrapping and non-wrapping printer.
// See https://github.com/sharkdp/bat/issues/2307 for what common use case this test tests.
#[test]