Skip to content

Commit

Permalink
refactor: rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgalarraga committed Jun 28, 2024
1 parent fbeaf3b commit edea8d8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ class CrosswordRepository {
oldString.substring(index + 1);
}

/// Adds one to the solved words count in the crossword.
Future<void> updateSolvedWordsCount(String wordId) async {
/// Creates a new document for a solved word
Future<void> saveSolvedWord(String wordId) async {
await _dbClient.set(
_solvedWordCollection,
DbEntityRecord(id: wordId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void main() {
);
});

group('updateSolvedWordsCount', () {
group('saveSolvedWord', () {
late CrosswordRepository repository;

setUp(() {
Expand All @@ -537,7 +537,7 @@ void main() {
() => dbClient.set('solvedWords', any()),
).thenAnswer((_) async {});

await repository.updateSolvedWordsCount('id');
await repository.saveSolvedWord('id');

verify(
() => dbClient.set(
Expand Down
2 changes: 1 addition & 1 deletion api/routes/game/answer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<Response> _onPost(RequestContext context) async {
points = await leaderboardRepository.updateScore(user.id);

if (!preSolved) {
await crosswordRepository.updateSolvedWordsCount(wordId);
await crosswordRepository.saveSolvedWord(wordId);
}
}

Expand Down
6 changes: 3 additions & 3 deletions api/test/routes/game/answer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void main() {
final response = await route.onRequest(requestContext);

expect(response.statusCode, HttpStatus.ok);
verifyNever(() => crosswordRepository.updateSolvedWordsCount(any()));
verifyNever(() => crosswordRepository.saveSolvedWord(any()));
},
);

Expand All @@ -153,7 +153,7 @@ void main() {
),
);
when(
() => crosswordRepository.updateSolvedWordsCount('id'),
() => crosswordRepository.saveSolvedWord('id'),
).thenAnswer((_) async {});
when(
() => crosswordRepository.answerWord(
Expand All @@ -177,7 +177,7 @@ void main() {

expect(response.statusCode, HttpStatus.ok);
verify(
() => crosswordRepository.updateSolvedWordsCount('id'),
() => crosswordRepository.saveSolvedWord('id'),
).called(1);
},
);
Expand Down

0 comments on commit edea8d8

Please sign in to comment.