mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Fix test
This commit is contained in:
@@ -48,15 +48,9 @@ class TrophyRepository {
|
||||
}
|
||||
|
||||
Future<List<UserTrophyProgression>> fetchProgression() async {
|
||||
try {
|
||||
final url = base.makeUrl(userTrophyProgressionPath);
|
||||
final List<dynamic> data = await base.fetch(url);
|
||||
return data.map((e) => UserTrophyProgression.fromJson(e)).toList();
|
||||
} catch (e, stck) {
|
||||
print('Error fetching trophy progression: $e');
|
||||
print(stck);
|
||||
return [];
|
||||
}
|
||||
final url = base.makeUrl(userTrophyProgressionPath);
|
||||
final List<dynamic> data = await base.fetch(url);
|
||||
return data.map((e) => UserTrophyProgression.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
List<Trophy> filterByType(List<Trophy> list, TrophyType type) =>
|
||||
|
||||
@@ -77,15 +77,8 @@ void main() {
|
||||
};
|
||||
|
||||
final mockBase = MockWgerBaseProvider();
|
||||
when(mockBase.fetchPaginated(any)).thenAnswer((_) async => [progressionJson]);
|
||||
when(
|
||||
mockBase.makeUrl(
|
||||
any,
|
||||
id: anyNamed('id'),
|
||||
objectMethod: anyNamed('objectMethod'),
|
||||
query: anyNamed('query'),
|
||||
),
|
||||
).thenReturn(Uri.parse('https://example.org/user_progressions'));
|
||||
when(mockBase.fetch(any)).thenAnswer((_) async => [progressionJson]);
|
||||
when(mockBase.makeUrl(any)).thenReturn(Uri.parse('https://example.org/user_progressions'));
|
||||
final repository = TrophyRepository(mockBase);
|
||||
|
||||
// Act
|
||||
@@ -100,7 +93,7 @@ void main() {
|
||||
expect(p.currentValue, 12.5);
|
||||
expect(p.progressDisplay, '12.5/100');
|
||||
|
||||
verify(mockBase.fetchPaginated(any)).called(1);
|
||||
verify(mockBase.fetch(any)).called(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user