Skip to content

Commit

Permalink
test(path utils): improves test cases PE-4923
Browse files Browse the repository at this point in the history
  • Loading branch information
matibat committed Nov 7, 2023
1 parent 51ad6b3 commit bd97a88
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test/src/utils/path_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,54 @@ void main() {
group('getFileTypeFromMime method', () {
test('should return the file type from mimetype', () {
final type = getFileTypeFromMime(contentType: 'application/pdf');

expect(type, 'pdf');
});

test('should return the file type for a different mimetype', () {
final type = getFileTypeFromMime(contentType: 'image/jpeg');
expect(type, 'jpeg');
});

test('should return null for an empty string', () {
final type = getFileTypeFromMime(contentType: '');
expect(type, '');
});
});

group('getBasenameWithoutExtension method', () {
test('should return the basename without extension', () {
final basename = getBasenameWithoutExtension(
filePath: '/hola/que/tal/file.pdf',
);
expect(basename, 'file');
});

test('should return the basename without extension', () {
final basename = getBasenameWithoutExtension(
filePath: '/hola/que/tal/file.pdf.txt',
);
expect(basename, 'file.pdf');
});

test('should return the basename for a different file path', () {
final basename = getBasenameWithoutExtension(
filePath: '/another/path/to/different.file',
);
expect(basename, 'different');
});

test('should return the basename for a file path without extension', () {
final basename = getBasenameWithoutExtension(
filePath: '/path/to/file',
);
expect(basename, 'file');
});

test('should return an empty string for an empty string', () {
final basename = getBasenameWithoutExtension(
filePath: '',
);
expect(basename, '');
});
});
}

0 comments on commit bd97a88

Please sign in to comment.