Skip to content

Commit

Permalink
. t testpath to helper, another one for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed May 18, 2024
1 parent 78d7431 commit 95cb40b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
25 changes: 8 additions & 17 deletions test/groups/minor_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.",
);
Expand All @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions test/utils/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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';
}
}
}

0 comments on commit 95cb40b

Please sign in to comment.