From 91f6707fb186279a505fdb69456d11dbf93870fd Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sun, 27 Dec 2020 22:03:22 +0000 Subject: Add tests of hunk-header-style special attributes --- src/tests/test_example_diffs.rs | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index 3530b29d..402a88a5 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -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"]); @@ -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(&[ -- cgit v1.2.3