From 715de197d77cb1d181ae71779b8271beec9c8d28 Mon Sep 17 00:00:00 2001 From: Yelaman Yelmuratov Date: Sat, 18 May 2024 01:52:15 +0500 Subject: [PATCH] . r formatted, deleted colorize --- lib/approval_tests.dart | 1 - lib/src/reporters/command_line/colorize.dart | 19 ------------------- .../command_line/command_line_reporter.dart | 6 +++++- .../diff_tool/diff_tool_reporter.dart | 3 ++- lib/src/reporters/diff_tool/diff_tools.dart | 3 +-- test/approval_test.dart | 11 ++++++++--- 6 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 lib/src/reporters/command_line/colorize.dart diff --git a/lib/approval_tests.dart b/lib/approval_tests.dart index a4fb29a..808e0b5 100644 --- a/lib/approval_tests.dart +++ b/lib/approval_tests.dart @@ -27,7 +27,6 @@ part 'src/exceptions/doesnt_match_exception.dart'; part 'src/exceptions/ide_comparator_exception.dart'; part 'src/namer/file_namer_options.dart'; part 'src/namer/namer.dart'; -part 'src/reporters/command_line/colorize.dart'; part 'src/reporters/command_line/command_line_reporter.dart'; part 'src/reporters/diff_tool/diff_info.dart'; part 'src/reporters/diff_tool/diff_tool_reporter.dart'; diff --git a/lib/src/reporters/command_line/colorize.dart b/lib/src/reporters/command_line/colorize.dart deleted file mode 100644 index 6afcdef..0000000 --- a/lib/src/reporters/command_line/colorize.dart +++ /dev/null @@ -1,19 +0,0 @@ -part of '../../../approval_tests.dart'; - -enum _LogColorStyles { red, bgRed } - -class _Colorize { - static const String esc = "\u{1B}["; - final String text; - - const _Colorize(this.text); - - _Colorize apply(_LogColorStyles style) { - final appliedText = - "$esc${style == _LogColorStyles.red ? '38;2;222;121;121' : '41'}m$text${esc}0m"; - return _Colorize(appliedText); - } - - @override - String toString() => text; -} diff --git a/lib/src/reporters/command_line/command_line_reporter.dart b/lib/src/reporters/command_line/command_line_reporter.dart index 3f2b09a..0054b5b 100644 --- a/lib/src/reporters/command_line/command_line_reporter.dart +++ b/lib/src/reporters/command_line/command_line_reporter.dart @@ -39,7 +39,11 @@ class CommandLineReporter implements Reporter { } } - String _highlightDifference(String approvedLine, String receivedLine, {bool isApprovedFile = false}) { + String _highlightDifference( + String approvedLine, + String receivedLine, { + bool isApprovedFile = false, + }) { // Create a new instance of DiffMatchPatch final differ = DiffMatchPatch(); diff --git a/lib/src/reporters/diff_tool/diff_tool_reporter.dart b/lib/src/reporters/diff_tool/diff_tool_reporter.dart index 6fbda39..1144d0a 100644 --- a/lib/src/reporters/diff_tool/diff_tool_reporter.dart +++ b/lib/src/reporters/diff_tool/diff_tool_reporter.dart @@ -29,7 +29,8 @@ class DiffReporter implements Reporter { rethrow; } throw IDEComparatorException( - message: 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.', + message: + 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.', exception: e, stackTrace: st, ); diff --git a/lib/src/reporters/diff_tool/diff_tools.dart b/lib/src/reporters/diff_tool/diff_tools.dart index 1d1386e..9c80a71 100644 --- a/lib/src/reporters/diff_tool/diff_tools.dart +++ b/lib/src/reporters/diff_tool/diff_tools.dart @@ -3,8 +3,7 @@ part of '../../../../approval_tests.dart'; /// `MacDiffTools` contains diff tools available on macOS. final class MacDiffTools { static const DiffInfo visualStudioCode = DiffInfo( - command: - '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code', + command: '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code', arg: '-d', ); diff --git a/test/approval_test.dart b/test/approval_test.dart index 924f8b7..1d6acca 100644 --- a/test/approval_test.dart +++ b/test/approval_test.dart @@ -94,7 +94,8 @@ void main() { ); }); - test("Method «verify» must throw DoesntMatchException with error handling", () { + test("Method «verify» must throw DoesntMatchException with error handling", + () { expect( () => helper.verify( 'Hello W0rld', @@ -115,7 +116,9 @@ void main() { ApprovalLogger.log("$lines25 Group: Minor cases are starting $lines25"); }); - test('Simulate file not found error during comparison. Must throw CommandLineComparatorException.', () async { + test( + 'Simulate file not found error during comparison. Must throw CommandLineComparatorException.', + () async { const comparator = FileComparator(); // Setup: paths to non-existent files @@ -136,7 +139,9 @@ void main() { ); }); - test('Simulate file not found error during comparison. Must throw IDEComparatorException.', () async { + test( + 'Simulate file not found error during comparison. Must throw IDEComparatorException.', + () async { const reporter = DiffReporter(); // Setup: paths to non-existent files