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