Skip to content

Commit

Permalink
Add failing test of hunk-header-style 'file' attribute
Browse files Browse the repository at this point in the history
Ref #309
  • Loading branch information
dandavison committed Dec 19, 2020
1 parent 31066fc commit 8685978
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/parse_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ fn parse_ansi_term_style(
style.is_strikethrough = true;
} else if word == "ul" || word == "underline" {
style.is_underline = true;
} else if word == "file" {
// Ignore without error: this is meaningful in hunk-header-style.
} else if !seen_foreground {
if word == "syntax" {
is_syntax_highlighted = true;
Expand Down
21 changes: 21 additions & 0 deletions src/tests/test_example_diffs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,27 @@ src/align.rs
assert!(output.contains("@@ -71,11 +71,8 @@ impl<'a> Alignment<'a> {"));
}

#[test]
fn test_hunk_header_style_with_file() {
let config = integration_test_utils::make_config_from_args(&[
"--file-style",
"yellow",
"--hunk-header-style",
"file red",
]);
let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);

ansi_test_utils::assert_line_has_style(
&output,
11,
"src/align.rs: impl<'a> Alignment<'a> {",
"yellow",
&config,
);
let output = strip_ansi_codes(&output);
assert!(output.contains("src/align.rs: impl<'a> Alignment<'a> {"));
}

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

0 comments on commit 8685978

Please sign in to comment.