From 95cb40b58dd72d57abd9a53cb4f8697d650cf620 Mon Sep 17 00:00:00 2001 From: Yelaman Yelmuratov Date: Sat, 18 May 2024 23:22:12 +0500 Subject: [PATCH] . t testpath to helper, another one for windows --- test/groups/minor_tests.dart | 25 ++++++++----------------- test/utils/helper.dart | 11 +++++++++-- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/test/groups/minor_tests.dart b/test/groups/minor_tests.dart index 1ba866c..8e74ee7 100644 --- a/test/groups/minor_tests.dart +++ b/test/groups/minor_tests.dart @@ -10,9 +10,7 @@ void minorTests({ ApprovalLogger.log("$lines25 Group: Minor tests are starting $lines25"); }); - test( - 'Simulate file not found error during comparison. Must throw PathNotFoundException.', - () async { + test('Simulate file not found error during comparison. Must throw PathNotFoundException.', () async { const comparator = FileComparator(); // Setup: paths to non-existent files @@ -33,9 +31,7 @@ void minorTests({ ); }); - 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 @@ -91,17 +87,14 @@ void minorTests({ }); // if (Platform.isLinux) { - test('Verify string with DiffReporter. Must throw IDEComparatorException.', - () async { + test('Verify string with DiffReporter. Must throw IDEComparatorException.', () async { const reporter = DiffReporter( customDiffInfo: LinuxDiffTools.visualStudioCode, ); // Setup: paths to non-existent files - const existentApprovedPath = - 'test/approved_files/approval_test.verify.approved.txt'; - const existentReceivedPath = - 'test/approved_files/approval_test.verify.received.txt'; + const existentApprovedPath = 'test/approved_files/approval_test.verify.approved.txt'; + const existentReceivedPath = 'test/approved_files/approval_test.verify.received.txt'; // Expect an exception to be thrown expect( @@ -151,11 +144,10 @@ void minorTests({ 'file:///path/to/file.dart:10:11\nother stack trace lines...', ); - const filePathExtractor = - FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher); + const filePathExtractor = FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher); final filePath = filePathExtractor.filePath; - expect(filePath, '/path/to/file.dart'); + expect(filePath, helper.testPath); ApprovalLogger.success( "Test Passed: Successfully extracted the file path from the stack trace.", ); @@ -166,8 +158,7 @@ void minorTests({ 'no file path in this stack trace\nother stack trace lines...', ); - const filePathExtractor = - FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher); + const filePathExtractor = FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher); expect( () => filePathExtractor.filePath, diff --git a/test/utils/helper.dart b/test/utils/helper.dart index 231f9f3..60d68fa 100644 --- a/test/utils/helper.dart +++ b/test/utils/helper.dart @@ -55,8 +55,7 @@ class ApprovalTestHelper { }) { Approvals.verifyAll( contents, - processor: (item) => item - .toString(), // Simple processor function that returns the item itself. + processor: (item) => item.toString(), // Simple processor function that returns the item itself. options: _getOptions( testName, expectException: expectException, @@ -166,4 +165,12 @@ class ApprovalTestHelper { reporter: reporter, scrubber: scrubber, ); + + String get testPath { + if (Platform.isWindows) { + return '\\path\\to\\file.dart'; + } else { + return '/path/to/file.dart'; + } + } }