summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFilip Razek <filip.razek@protonmail.com>2024-01-21 17:13:11 +0100
committerDavid Peter <sharkdp@users.noreply.github.com>2024-01-21 19:48:26 +0100
commit45ee2dc4c7277b4697d5b330f59e8ed5efcce99c (patch)
treec3eb8312787ab5ad38ac7a735c46c6948501270c /tests
parentdb66e4459bc4e66c03629d7cbc235f59245280c0 (diff)
fix: Wrap file name in header
Diffstat (limited to 'tests')
-rw-r--r--tests/examples/this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt1
-rw-r--r--tests/integration_tests.rs55
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/examples/this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt b/tests/examples/this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt
new file mode 100644
index 00000000..4dac98dc
--- /dev/null
+++ b/tests/examples/this-file-path-is-really-long-and-would-have-broken-the-layout-of-the-header.txt
@@ -0,0 +1 @@
+The header is not broken \ No newline at end of file
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index be70fdca..10564f3a 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -1382,6 +1382,61 @@ fn header_full_binary() {
}
#[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() {
bat()