This commit is contained in:
Roland Geider committed 2025-12-20 21:34:33 +01:00
1 parent 36a3e7ef4a
commit 0774571fbc
2 files changed
+6 -19

No files matched your search

+3 -9
View File
@@ -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);
});
});
}