fix: Wrap file name in header

This commit is contained in:
Filip Razek
2024-01-21 17:13:11 +01:00
committed by David Peter
parent db66e4459b
commit 45ee2dc4c7
4 changed files with 88 additions and 14 deletions

View File

@ -1381,6 +1381,61 @@ fn header_full_binary() {
.stderr("");
}
#[test]
fn header_narrow_terminal() {
bat()
.arg("--terminal-width=30")
.arg("--decorations=always")
.arg("this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt")
.assert()
.success()
.stdout(
"\
───────┬──────────────────────
│ File: this-file-path-
│ is-really-long-and-wo
│ uld-have-broken-the-l
│ ayout-of-the-header.t
│ xt
───────┼──────────────────────
1 │ The header is not bro
│ ken
───────┴──────────────────────
",
)
.stderr("");
}
#[test]
fn header_very_narrow_terminal() {
bat()
.arg("--terminal-width=10")
.arg("--decorations=always")
.arg("this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt")
.assert()
.success()
.stdout(
"\
──────────
File: this
-file-path
-is-really
-long-and-
would-have
-broken-th
e-layout-o
f-the-head
er.txt
──────────
The header
is not br
oken
──────────
",
)
.stderr("");
}
#[test]
#[cfg(feature = "git")] // Expected output assumes git is enabled
fn header_default() {