refactor(profile): update ProfileRepository to include Ref for improved state management and enhance error handling in tests

This commit is contained in:
Nils-Johan Gynther
2026-04-23 17:55:17 +02:00
parent aefc8804ad
commit 2256ddb29b
3 changed files with 14 additions and 5 deletions
@@ -28,7 +28,7 @@ void main() {
});
test('should throw ApiException when API call fails', () async {
when(mockApiClient.getJson('/api/profile')).thenThrow(ApiException('Failed to fetch profile'));
when(mockApiClient.getJson('/api/profile')).thenThrow(ApiException(message: 'Failed to fetch profile'));
expect(() => profileRepository.getProfile(), throwsA(isA<ApiException>()));
verify(mockApiClient.getJson('/api/profile')).called(1);
@@ -49,7 +49,7 @@ void main() {
test('should throw ApiException when API call fails', () async {
final profileData = {'username': 'newuser', 'email': 'new@example.com'};
when(mockApiClient.patchJson('/api/profile', profileData)).thenThrow(ApiException('Failed to update profile'));
when(mockApiClient.patchJson('/api/profile', profileData)).thenThrow(ApiException(message: 'Failed to update profile'));
expect(() => profileRepository.updateProfile(profileData), throwsA(isA<ApiException>()));
verify(mockApiClient.patchJson('/api/profile', profileData)).called(1);