refactor(profile): update ProfileRepository to include Ref for improved state management and enhance error handling in tests
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user