Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
julien4215 committed Mar 3, 2024
1 parent 9af68be commit 04543cd
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/view/user/perf_stats_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ class _Body extends ConsumerWidget {
data: (data) {
return ratingHistory.when(
data: (ratingHistoryData) {
final ratingHistoryPerfData = ratingHistoryData
.where((element) => element.perf == perf.title)
.first;
return SafeArea(
child: ListView(
padding: Styles.bodyPadding,
scrollDirection: Axis.vertical,
children: [
_EloChart(
ratingHistoryData
.where((element) => element.perf == perf.title)
.first,
),
if (ratingHistoryPerfData.points.isNotEmpty)
_EloChart(ratingHistoryPerfData),
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
Expand Down
74 changes: 74 additions & 0 deletions test/view/user/perf_stats_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class FakeClientFactory implements LichessClientFactory {
'/api/user/${fakeUser.id}/perf/${testPerf.name}') {
return mockResponse(userPerfStatsResponse, 200);
}
if (request.url.path == '/api/user/${fakeUser.id}/rating-history') {
return mockResponse(userRatingHistoryResponse, 200);
}
return mockResponse('', 404);
});
}
Expand Down Expand Up @@ -342,3 +345,74 @@ final userPerfStatsResponse = '''
}
}
''';
const userRatingHistoryResponse = '''
[
{
"name": "Bullet",
"points": [
[
2016,
0,
2,
2617
]
]
},
{
"name": "Blitz",
"points": []
},
{
"name": "Rapid",
"points": []
},
{
"name": "Classical",
"points": []
},
{
"name": "Correspondence",
"points": []
},
{
"name": "Chess960",
"points": []
},
{
"name": "King of the Hill",
"points": []
},
{
"name": "Three-check",
"points": []
},
{
"name": "Antichess",
"points": []
},
{
"name": "Atomic",
"points": []
},
{
"name": "Horde",
"points": []
},
{
"name": "Racing Kings",
"points": []
},
{
"name": "Crazyhouse",
"points": []
},
{
"name": "Puzzles",
"points": []
},
{
"name": "UltraBullet",
"points": []
}
]
''';

0 comments on commit 04543cd

Please sign in to comment.