Fixed tests
This commit is contained in:
@@ -93,7 +93,6 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
|
||||
// Get the current nameCount
|
||||
var nameCount = await calculateNameCount(name: name);
|
||||
if (nameCount == 0) nameCount++;
|
||||
|
||||
// One player with the same name
|
||||
if (playersWithName.length == 1) {
|
||||
@@ -108,6 +107,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (nameCount == 0) nameCount++;
|
||||
// Multiple players with the same name
|
||||
for (var i = 0; i < playersWithName.length; i++) {
|
||||
final player = playersWithName[i];
|
||||
|
||||
@@ -449,8 +449,8 @@ void main() {
|
||||
);
|
||||
|
||||
test('getNameCount works correctly', () async {
|
||||
final player2 = Player(name: testPlayer1.name, description: '');
|
||||
final player3 = Player(name: testPlayer1.name, description: '');
|
||||
final player2 = Player(name: testPlayer1.name);
|
||||
final player3 = Player(name: testPlayer1.name);
|
||||
|
||||
await database.playerDao.addPlayersAsList(
|
||||
players: [testPlayer1, player2, player3],
|
||||
@@ -460,7 +460,7 @@ void main() {
|
||||
name: testPlayer1.name,
|
||||
);
|
||||
|
||||
expect(nameCount, 2);
|
||||
expect(nameCount, 3);
|
||||
});
|
||||
|
||||
test('updateNameCount works correctly', () async {
|
||||
@@ -470,14 +470,12 @@ void main() {
|
||||
playerId: testPlayer1.id,
|
||||
nameCount: 2,
|
||||
);
|
||||
|
||||
expect(success, true);
|
||||
|
||||
final nameCount = await database.playerDao.getNameCount(
|
||||
name: testPlayer1.name,
|
||||
final player = await database.playerDao.getPlayerById(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
|
||||
expect(nameCount, 2);
|
||||
expect(player.nameCount, 2);
|
||||
});
|
||||
|
||||
test('getPlayerWithHighestNameCount works correctly', () async {
|
||||
|
||||
Reference in New Issue
Block a user