diff --git a/test/core/image_compressing/image_compress_utility_test.dart b/test/core/image_compressing/image_compress_utility_test.dart index 9f619520..456543f2 100644 --- a/test/core/image_compressing/image_compress_utility_test.dart +++ b/test/core/image_compressing/image_compress_utility_test.dart @@ -426,5 +426,27 @@ void main() { } } }); + + test('compressFile - does not crash on corrupted image', () async { + final file = File('corrupted.jpg'); + + try { + await file.writeAsBytes([ + 0xFF, 0xD8, 0xFF, 0xE0, + 0x00, 0x10, + 0x4A, 0x46, 0x49, 0x46, + 0xFF, 0xDA, + ]); + + final result = await ImageCompressUtility.compressFile(file); + + expect(result, isA()); + expect(result.path, file.path); + } finally { + if (await file.exists()) { + await file.delete(); + } + } + }); }); }