Skip to content

Commit

Permalink
refactor: rename Mascots enum to Mascot
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgalarraga committed Jun 5, 2024
1 parent 7133427 commit 55a90c9
Show file tree
Hide file tree
Showing 56 changed files with 317 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CrosswordRepository {
/// The second value returns true if the answer was previously answered.
Future<(bool, bool)> answerWord(
String wordId,
Mascots mascot,
Mascot mascot,
String userAnswer,
) async {
final correctAnswer = await findAnswerById(wordId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void main() {
answer: 'solved',
clue: '',
solvedTimestamp: 12343,
mascot: Mascots.sparky,
mascot: Mascot.sparky,
);

setUp(() {
Expand Down Expand Up @@ -296,8 +296,7 @@ void main() {
final time = DateTime.now();
final clock = Clock.fixed(time);
await withClock(clock, () async {
final valid =
await repository.answerWord('4', Mascots.dino, 'solved');
final valid = await repository.answerWord('4', Mascot.dino, 'solved');
expect(valid, (true, true));
});
});
Expand All @@ -308,7 +307,7 @@ void main() {
final clock = Clock.fixed(time);
await withClock(clock, () async {
final valid =
await repository.answerWord('1', Mascots.dino, 'flutter');
await repository.answerWord('1', Mascot.dino, 'flutter');
expect(valid, (true, false));

verify(
Expand Down Expand Up @@ -338,7 +337,7 @@ void main() {
word
.copyWith(
solvedTimestamp: time.millisecondsSinceEpoch,
mascot: Mascots.dino,
mascot: Mascot.dino,
answer: 'flutter',
)
.toJson(),
Expand All @@ -352,7 +351,7 @@ void main() {
});

test('returns (false, false) if answer is incorrect', () async {
final valid = await repository.answerWord('1', Mascots.dino, 'android');
final valid = await repository.answerWord('1', Mascot.dino, 'android');
expect(valid, (false, false));
});

Expand All @@ -363,7 +362,7 @@ void main() {
() => dbClient.getById(answersCollection, 'fake'),
).thenAnswer((_) async => null);
expect(
() => repository.answerWord('fake', Mascots.dino, 'flutter'),
() => repository.answerWord('fake', Mascot.dino, 'flutter'),
throwsA(isA<CrosswordRepositoryException>()),
);
},
Expand Down Expand Up @@ -396,7 +395,7 @@ void main() {
).thenAnswer((_) async => answersRecord);

expect(
() => repository.answerWord('3', Mascots.sparky, 'happy'),
() => repository.answerWord('3', Mascot.sparky, 'happy'),
throwsA(isA<CrosswordRepositoryException>()),
);
},
Expand All @@ -413,7 +412,7 @@ void main() {
).thenAnswer((_) async => []);

expect(
() => repository.answerWord('1', Mascots.dino, 'flutter'),
() => repository.answerWord('1', Mascot.dino, 'flutter'),
throwsA(isA<CrosswordRepositoryException>()),
);
},
Expand All @@ -435,7 +434,7 @@ void main() {
() => dbClient.getById(answersCollection, 'fake'),
).thenAnswer((_) async => answersRecord);
expect(
() => repository.answerWord('fake', Mascots.dino, 'flutter'),
() => repository.answerWord('fake', Mascot.dino, 'flutter'),
throwsA(isA<CrosswordRepositoryException>()),
);
},
Expand Down
2 changes: 1 addition & 1 deletion api/packages/game_domain/lib/src/models/mascots.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// {@template mascots}
/// Google Mascots enum.
/// {@endtemplate}
enum Mascots {
enum Mascot {
/// Flutter Dash mascot.
dash,

Expand Down
6 changes: 3 additions & 3 deletions api/packages/game_domain/lib/src/models/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Player extends Equatable {
static const empty = Player(
id: '',
initials: '',
mascot: Mascots.dash,
mascot: Mascot.dash,
);

/// Unique identifier of the leaderboard player object
Expand All @@ -47,14 +47,14 @@ class Player extends Equatable {

/// The player mascot.
@JsonKey()
final Mascots mascot;
final Mascot mascot;

/// Returns a copy of [Player] this instance with the
/// provided fields.
Player copyWith({
String? id,
String? initials,
Mascots? mascot,
Mascot? mascot,
int? score,
int? streak,
}) {
Expand Down
14 changes: 7 additions & 7 deletions api/packages/game_domain/lib/src/models/player.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/packages/game_domain/lib/src/models/word.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Word extends Equatable {
/// The mascot of the user that first solved the word.
/// If the word is not solved, this value is null.
@JsonKey()
final Mascots? mascot;
final Mascot? mascot;

/// Returns the solved characters with the index position and character
/// solved.
Expand Down Expand Up @@ -95,7 +95,7 @@ class Word extends Equatable {
String? clue,
String? answer,
int? solvedTimestamp,
Mascots? mascot,
Mascot? mascot,
}) {
return Word(
id: id ?? this.id,
Expand Down
14 changes: 7 additions & 7 deletions api/packages/game_domain/lib/src/models/word.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
answer: 'answer',
clue: 'clue',
solvedTimestamp: 1234,
mascot: Mascots.android,
mascot: Mascot.android,
),
],
);
Expand Down Expand Up @@ -74,7 +74,7 @@ void main() {
answer: 'answer',
clue: 'clue',
solvedTimestamp: 1234,
mascot: Mascots.android,
mascot: Mascot.android,
),
],
),
Expand Down
28 changes: 14 additions & 14 deletions api/packages/game_domain/test/src/models/player_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
Player(
id: '',
initials: '',
mascot: Mascots.dash,
mascot: Mascot.dash,
),
),
);
Expand All @@ -24,7 +24,7 @@ void main() {
id: 'id',
initials: 'TST',
score: 10,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
),
isNotNull,
Expand All @@ -35,7 +35,7 @@ void main() {
id: 'id',
initials: 'TST',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
);

Expand All @@ -45,7 +45,7 @@ void main() {
equals({
'initials': 'TST',
'score': 20,
'mascot': Mascots.android.name,
'mascot': Mascot.android.name,
'streak': 2,
}),
);
Expand All @@ -57,7 +57,7 @@ void main() {
'id': 'id',
'initials': 'TST',
'score': 20,
'mascot': Mascots.android.name,
'mascot': Mascot.android.name,
'streak': 2,
}),
equals(leaderboardPlayer),
Expand All @@ -70,15 +70,15 @@ void main() {
id: '',
initials: 'TST',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
),
equals(
Player(
id: '',
initials: 'TST',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
),
),
Expand All @@ -89,7 +89,7 @@ void main() {
id: '',
initials: 'TST',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
),
isNot(
Expand All @@ -102,7 +102,7 @@ void main() {
id: 'id',
initials: 'WOW',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 2,
),
isNot(
Expand All @@ -115,7 +115,7 @@ void main() {
id: 'id',
initials: 'TST',
score: 20,
mascot: Mascots.dash,
mascot: Mascot.dash,
streak: 2,
),
isNot(
Expand All @@ -128,7 +128,7 @@ void main() {
id: 'id',
initials: 'TST',
score: 20,
mascot: Mascots.android,
mascot: Mascot.android,
streak: 3,
),
isNot(
Expand All @@ -142,19 +142,19 @@ void main() {
Player(
id: 'id',
initials: 'AAA',
mascot: Mascots.android,
mascot: Mascot.android,
streak: 10,
score: 500,
).copyWith(),
equals(
Player(
id: '',
initials: '',
mascot: Mascots.dash,
mascot: Mascot.dash,
).copyWith(
id: 'id',
initials: 'AAA',
mascot: Mascots.android,
mascot: Mascot.android,
streak: 10,
score: 500,
),
Expand Down
4 changes: 2 additions & 2 deletions api/packages/game_domain/test/src/models/word_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
answer: 'test',
clue: 'clue',
solvedTimestamp: 0,
mascot: Mascots.sparky,
mascot: Mascot.sparky,
);
final json = word.toJson();

Expand Down Expand Up @@ -50,7 +50,7 @@ void main() {
axis: WordAxis.horizontal,
answer: 'test',
clue: 'clue',
mascot: Mascots.sparky,
mascot: Mascot.sparky,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void main() {
id: 'userId',
score: 10,
streak: 1,
mascot: Mascots.dash,
mascot: Mascot.dash,
initials: 'ABC',
),
);
Expand All @@ -136,7 +136,7 @@ void main() {
id: 'userId',
score: 20,
streak: 1,
mascot: Mascots.dash,
mascot: Mascot.dash,
initials: 'ABC',
),
30,
Expand Down Expand Up @@ -208,7 +208,7 @@ void main() {
id: 'userId',
score: 20,
streak: 3,
mascot: Mascots.dash,
mascot: Mascot.dash,
initials: 'ABC',
),
),
Expand Down
Loading

0 comments on commit 55a90c9

Please sign in to comment.