From 3c31223dbfcbcb32c3c2da990091cc65e9f6eca1 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 19 Dec 2020 12:35:17 +0000 Subject: Add failing test of hunk-header-style 'file' attribute Ref #309 --- src/parse_style.rs | 2 ++ src/tests/test_example_diffs.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/parse_style.rs b/src/parse_style.rs index 565defa8..1fa4fb03 100644 --- a/src/parse_style.rs +++ b/src/parse_style.rs @@ -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" { + // Allow: this is meaningful in hunk-header-style. } else if !seen_foreground { if word == "syntax" { is_syntax_highlighted = true; diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index f4121588..72c4c5f0 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -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(&[ -- cgit v1.2.3