Added integration tests

This commit is contained in:
John Higgins 2022-10-09 22:42:11 -07:00
commit 8f31ffa9df
No known key found for this signature in database
GPG Key ID: 192DF5D301BD714C
2 changed files with 96 additions and 0 deletions

1
tests/examples/80-columns.txt vendored Normal file
View File

@ -0,0 +1 @@
abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz

View File

@ -1479,6 +1479,101 @@ fn ignored_suffix_arg() {
.stderr("");
}
#[test]
fn no_line_wrapping_when_set_to_never() {
let expected =
"───────┬────────────────────────────────────────────────────────────────────────
File: 80-columns.txt
Size: 101 B
1 abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz
";
bat()
.arg("--style=full")
.arg("--decorations=always")
.arg("--wrap=never")
.arg("--terminal-width=80")
.arg("80-columns.txt")
.assert()
.success()
.stdout(expected)
.stderr("");
}
#[test]
fn line_wrapping_when_auto() {
let expected =
"───────┬────────────────────────────────────────────────────────────────────────
File: 80-columns.txt
Size: 101 B
1 abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu
vxyzabcdefghigklmnopqrstuvxyz
";
bat()
.arg("--style=full")
.arg("--decorations=always")
.arg("--wrap=auto")
.arg("--terminal-width=80")
.arg("80-columns.txt")
.assert()
.success()
.stdout(expected)
.stderr("");
}
#[test]
fn line_wrapping_with_s_flag() {
let expected =
"───────┬────────────────────────────────────────────────────────────────────────
File: 80-columns.txt
Size: 101 B
1 abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu
vxyzabcdefghigklmnopqrstuvxyz
";
bat()
.arg("--style=full")
.arg("--decorations=always")
.arg("-S")
.arg("--terminal-width=80")
.arg("80-columns.txt")
.assert()
.success()
.stdout(expected)
.stderr("");
}
#[test]
fn chop_long_lines_when_specified() {
let expected =
"───────┬────────────────────────────────────────────────────────────────────────
File: 80-columns.txt
Size: 101 B
1 abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu
vxyzabcdefghigklmnopqrstuvxyz
";
bat()
.arg("--style=full")
.arg("--decorations=always")
.arg("--chop-long-lines")
.arg("--terminal-width=80")
.arg("80-columns.txt")
.assert()
.success()
.stdout(expected)
.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() +