remove winner tests
This commit is contained in:
@@ -278,86 +278,6 @@ void main() {
|
||||
expect(matchCount, 0);
|
||||
});
|
||||
|
||||
// Verifies that hasWinner correctly identifies matches with and without winners.
|
||||
test('Checking if match has winner works correctly', () async {
|
||||
await database.matchDao.addMatch(match: testMatch1);
|
||||
await database.matchDao.addMatch(match: testMatchOnlyGroup);
|
||||
|
||||
var hasWinner = await database.matchDao.hasWinner(matchId: testMatch1.id);
|
||||
expect(hasWinner, true);
|
||||
|
||||
hasWinner = await database.matchDao.hasWinner(
|
||||
matchId: testMatchOnlyGroup.id,
|
||||
);
|
||||
expect(hasWinner, false);
|
||||
});
|
||||
|
||||
// Verifies that getWinner returns the correct winner player for a match.
|
||||
test('Fetching the winner of a match works correctly', () async {
|
||||
await database.matchDao.addMatch(match: testMatch1);
|
||||
|
||||
final winner = await database.matchDao.getWinner(matchId: testMatch1.id);
|
||||
if (winner == null) {
|
||||
fail('Winner is null');
|
||||
} else {
|
||||
expect(winner.id, testMatch1.winner!.id);
|
||||
expect(winner.name, testMatch1.winner!.name);
|
||||
expect(winner.createdAt, testMatch1.winner!.createdAt);
|
||||
}
|
||||
});
|
||||
|
||||
// Verifies that setWinner correctly updates the winner of a match.
|
||||
test('Updating the winner of a match works correctly', () async {
|
||||
await database.matchDao.addMatch(match: testMatch1);
|
||||
|
||||
final winner = await database.matchDao.getWinner(matchId: testMatch1.id);
|
||||
if (winner == null) {
|
||||
fail('Winner is null');
|
||||
} else {
|
||||
expect(winner.id, testMatch1.winner!.id);
|
||||
expect(winner.name, testMatch1.winner!.name);
|
||||
expect(winner.createdAt, testMatch1.winner!.createdAt);
|
||||
expect(winner.id, testPlayer4.id);
|
||||
expect(winner.id != testPlayer5.id, true);
|
||||
}
|
||||
|
||||
await database.matchDao.setWinner(
|
||||
matchId: testMatch1.id,
|
||||
winnerId: testPlayer5.id,
|
||||
);
|
||||
|
||||
final newWinner = await database.matchDao.getWinner(
|
||||
matchId: testMatch1.id,
|
||||
);
|
||||
|
||||
if (newWinner == null) {
|
||||
fail('New winner is null');
|
||||
} else {
|
||||
expect(newWinner.id, testPlayer5.id);
|
||||
expect(newWinner.name, testPlayer5.name);
|
||||
expect(newWinner.createdAt, testPlayer5.createdAt);
|
||||
}
|
||||
});
|
||||
|
||||
// Verifies that removeWinner clears the winner and hasWinner returns false.
|
||||
test('Removing a winner works correctly', () async {
|
||||
await database.matchDao.addMatch(match: testMatch2);
|
||||
|
||||
var hasWinner = await database.matchDao.hasWinner(matchId: testMatch2.id);
|
||||
expect(hasWinner, true);
|
||||
|
||||
await database.matchDao.removeWinner(matchId: testMatch2.id);
|
||||
|
||||
hasWinner = await database.matchDao.hasWinner(matchId: testMatch2.id);
|
||||
expect(hasWinner, false);
|
||||
|
||||
final removedWinner = await database.matchDao.getWinner(
|
||||
matchId: testMatch2.id,
|
||||
);
|
||||
|
||||
expect(removedWinner, null);
|
||||
});
|
||||
|
||||
// Verifies that updateMatchName correctly updates only the name field.
|
||||
test('Renaming a match works correctly', () async {
|
||||
await database.matchDao.addMatch(match: testMatch1);
|
||||
|
||||
Reference in New Issue
Block a user