Skip to content

Commit

Permalink
testing image selection
Browse files Browse the repository at this point in the history
  • Loading branch information
MayankJha014 committed Jan 3, 2025
1 parent e99e8d5 commit ce3deaf
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,11 @@ Future<void> main() async {

// Mock setting an image file
final model = EditProfilePageViewModel();
model.imageFile = File('mockPath');

// Mock file with proper cleanup
final tempDir = await Directory.systemTemp.createTemp();
final file = File('${tempDir.path}/test.png');
await file.writeAsString('mock data');
model.imageFile = file;
// Rebuild the widget to reflect the new state
await tester
.pumpWidget(createEditProfilePage(themeMode: ThemeMode.dark));
Expand All @@ -557,6 +560,20 @@ Future<void> main() async {

// Verify the image file is removed
expect(model.imageFile, isNull);

// Verify UI feedback
expect(find.byIcon(Icons.add_photo_alternate), findsOneWidget);

// Cleanup
await tempDir.delete(recursive: true);

// Test error handling
try {
model.imageFile = File('invalid_path');
fail('Should throw exception for invalid file');
} catch (e) {
expect(e, isInstanceOf<FileSystemException>());
}
});
});

Expand Down

0 comments on commit ce3deaf

Please sign in to comment.