Skip to content

Commit

Permalink
Add tests of hunk-header-style special attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Dec 27, 2020
1 parent 98782aa commit 91f6707
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/tests/test_example_diffs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,36 @@ impl<'a> Alignment<'a> {
_do_test_hunk_header_style_box(&["--hunk-header-decoration-style", "white box"]);
}

#[test]
fn test_hunk_header_style_box_line_number() {
_do_test_hunk_header_style_box(&[
"--hunk-header-style",
"line-number",
"--hunk-header-decoration-style",
"white box",
]);
}

#[test]
fn test_hunk_header_style_box_file_line_number() {
_do_test_hunk_header_style_box_file_line_number(&[
"--hunk-header-style",
"file line-number",
"--hunk-header-decoration-style",
"white box",
]);
}

#[test]
fn test_hunk_header_style_box_file() {
_do_test_hunk_header_style_box_file(&[
"--hunk-header-style",
"file",
"--hunk-header-decoration-style",
"white box",
]);
}

#[test]
fn test_hunk_header_style_box_deprecated_options() {
_do_test_hunk_header_style_box(&["--hunk-color", "white", "--hunk-style", "box"]);
Expand Down Expand Up @@ -1203,6 +1233,60 @@ impl<'a> Alignment<'a> {
));
}

fn _do_test_hunk_header_style_box_file(args: &[&str]) {
let config = integration_test_utils::make_config_from_args(args);
let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
ansi_test_utils::assert_line_has_style(
&output,
10,
"───────────────────────────────────────┐",
"white",
&config,
);
ansi_test_utils::assert_line_has_style(
&output,
12,
"───────────────────────────────────────┘",
"white",
&config,
);
let output = strip_ansi_codes(&output);
assert!(output.contains(
"
───────────────────────────────────────┐
src/align.rs: impl<'a> Alignment<'a> { │
───────────────────────────────────────┘
"
));
}

fn _do_test_hunk_header_style_box_file_line_number(args: &[&str]) {
let config = integration_test_utils::make_config_from_args(args);
let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
ansi_test_utils::assert_line_has_style(
&output,
10,
"──────────────────────────────────────────┐",
"white",
&config,
);
ansi_test_utils::assert_line_has_style(
&output,
12,
"──────────────────────────────────────────┘",
"white",
&config,
);
let output = strip_ansi_codes(&output);
assert!(output.contains(
"
──────────────────────────────────────────┐
src/align.rs:71: impl<'a> Alignment<'a> { │
──────────────────────────────────────────┘
"
));
}

#[test]
fn test_hunk_header_style_box_raw() {
let config = integration_test_utils::make_config_from_args(&[
Expand Down

0 comments on commit 91f6707

Please sign in to comment.