diff --git a/api/test/routes/game/leaderboard/initials/index_test.dart b/api/test/routes/game/leaderboard/initials/index_test.dart index ea5ea3585..8ad7adda2 100644 --- a/api/test/routes/game/leaderboard/initials/index_test.dart +++ b/api/test/routes/game/leaderboard/initials/index_test.dart @@ -91,6 +91,32 @@ void main() { expect(response.statusCode, equals(HttpStatus.noContent)); }); + test('responds with a 400 when mascot is not correct', () async { + final leaderboardPlayer = LeaderboardPlayer( + userId: 'user-id', + initials: 'AAA', + score: 10, + mascot: Mascots.dash, + streak: 2, + ); + + when(() => request.method).thenReturn(HttpMethod.post); + + when( + () => leaderboardRepository.addPlayerToLeaderboard( + leaderboardPlayer: leaderboardPlayer, + ), + ).thenAnswer((_) async {}); + + when(request.json).thenAnswer( + (_) async => leaderboardPlayer.toJson() + ..update('mascot', (value) => 'no-real-mascot'), + ); + + final response = await route.onRequest(context); + expect(response.statusCode, equals(HttpStatus.badRequest)); + }); + test('responds with a 400 when request is invalid', () async { when(() => request.method).thenReturn(HttpMethod.post); when(request.json).thenAnswer((_) async => {'test': 'test'}); @@ -106,6 +132,8 @@ void main() { 'userId': 'user-id', 'initials': 'CCC', 'score': 10, + 'mascot': 'dash', + 'streak': 2, }, ); @@ -121,6 +149,8 @@ void main() { 'userId': 'user-id', 'initials': 'ccc', 'score': 10, + 'mascot': 'dash', + 'streak': 2, }, ); @@ -137,6 +167,8 @@ void main() { 'userId': 'user-id', 'initials': 'aa', 'score': 10, + 'mascot': 'dash', + 'streak': 2, }, ); @@ -154,6 +186,8 @@ void main() { 'userId': 'user-id', 'initials': 'aaaa', 'score': 10, + 'mascot': 'dash', + 'streak': 2, }, );