diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-05-30 15:59:59 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-05-30 16:55:38 -0400 |
commit | a6de26c4eed802ebe45acb43ec9d50514adcdf61 (patch) | |
tree | 286688ebe90ac691db2d403a66a967288168d21e /src/tests | |
parent | 0fac9007c5bc807b1a6012a0fb48e7ce8701478d (diff) |
Add tests of `--ELEMENT-decoration-style omit`
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_example_diffs.rs | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index 9a771932..faef5831 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -2,6 +2,7 @@ mod tests { use console::strip_ansi_codes; + use crate::cli; use crate::tests::ansi_test_utils::ansi_test_utils; use crate::tests::integration_test_utils::integration_test_utils; @@ -223,6 +224,44 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e } #[test] + fn test_commit_decoration_style_omit() { + let mut options = integration_test_utils::get_command_line_options(); + options.commit_style = "blue".to_string(); + options.commit_decoration_style = "omit".to_string(); + _do_test_commit_style_no_decoration(options); + } + + #[test] + fn test_commit_decoration_style_empty_string() { + let mut options = integration_test_utils::get_command_line_options(); + options.commit_style = "blue".to_string(); + options.commit_decoration_style = "".to_string(); + _do_test_commit_style_no_decoration(options); + } + + fn _do_test_commit_style_no_decoration(options: cli::Opt) { + let (output, config) = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, options); + if false { + // `--commit-style xxx` is not honored yet: always behaves like xxx=raw + ansi_test_utils::assert_line_has_foreground_color( + &output, + 0, + "commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e", + "blue", + &config, + ); + } + let output = strip_ansi_codes(&output); + assert!(output.contains("commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e")); + assert!(!output.contains("commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e │")); + assert!(!output.contains( + "\ +commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e +───────────────────────────────────────────────" + )); + } + + #[test] fn test_commit_style_omit() { let mut options = integration_test_utils::get_command_line_options(); options.commit_style = "omit".to_string(); @@ -348,6 +387,44 @@ index 8e37a9e..6ce4863 100644 } #[test] + fn test_file_decoration_style_omit() { + let mut options = integration_test_utils::get_command_line_options(); + options.file_style = "green".to_string(); + options.file_decoration_style = "omit".to_string(); + _do_test_file_style_no_decoration(options); + } + + #[test] + fn test_file_decoration_style_empty_string() { + let mut options = integration_test_utils::get_command_line_options(); + options.file_style = "green".to_string(); + options.file_decoration_style = "".to_string(); + _do_test_file_style_no_decoration(options); + } + + fn _do_test_file_style_no_decoration(options: cli::Opt) { + let (output, config) = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, options); + if false { + // FIXME + ansi_test_utils::assert_line_has_foreground_color( + &output, + 7, + "src/align.rs", + "green", + &config, + ); + } + let output = strip_ansi_codes(&output); + assert!(output.contains("src/align.rs")); + assert!(!output.contains("src/align.rs │")); + assert!(!output.contains( + " +src/align.rs +────────────" + )); + } + + #[test] fn test_file_style_omit() { let mut options = integration_test_utils::get_command_line_options(); options.file_style = "omit".to_string(); @@ -451,6 +528,32 @@ src/align.rs } #[test] + fn test_hunk_header_decoration_style_omit() { + let mut options = integration_test_utils::get_command_line_options(); + options.hunk_header_decoration_style = "omit".to_string(); + _do_test_hunk_header_style_no_decoration(options); + } + + #[test] + fn test_hunk_header_decoration_style_empty_string() { + let mut options = integration_test_utils::get_command_line_options(); + options.hunk_header_decoration_style = "".to_string(); + _do_test_hunk_header_style_no_decoration(options); + } + + fn _do_test_hunk_header_style_no_decoration(options: cli::Opt) { + let (output, _) = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, options); + let output = strip_ansi_codes(&output); + assert!(output.contains(" impl<'a> Alignment<'a> {")); + assert!(!output.contains(" impl<'a> Alignment<'a> { │")); + assert!(!output.contains( + " + impl<'a> Alignment<'a> { +─────────────────────────" + )); + } + + #[test] fn test_hunk_header_style_omit() { let mut options = integration_test_utils::get_command_line_options(); options.hunk_header_style = "omit".to_string(); |