implement basic player_detail_view.dart
This commit is contained in:
@@ -194,6 +194,31 @@ void main() {
|
||||
expect(allGroups, isEmpty);
|
||||
});
|
||||
|
||||
test('getGroupsByPlayer() works correctly', () async {
|
||||
await database.groupDao.addGroupsAsList(
|
||||
groups: [testGroup1, testGroup2],
|
||||
);
|
||||
|
||||
final groups = await database.groupDao.getGroupsByPlayer(
|
||||
playerId: testPlayer2.id,
|
||||
);
|
||||
|
||||
expect(groups, hasLength(2));
|
||||
expect(groups.any((group) => group.id == testGroup1.id), isTrue);
|
||||
expect(groups.any((group) => group.id == testGroup2.id), isTrue);
|
||||
});
|
||||
|
||||
test(
|
||||
'getGroupsByPlayer() returns empty list for non-existent player',
|
||||
() async {
|
||||
final groups = await database.groupDao.getGroupsByPlayer(
|
||||
playerId: 'non-existent-player-id',
|
||||
);
|
||||
|
||||
expect(groups, isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
test('addGroupsAsList() with duplicate groups only adds once', () async {
|
||||
await database.groupDao.addGroupsAsList(
|
||||
groups: [testGroup1, testGroup1, testGroup1],
|
||||
|
||||
@@ -260,6 +260,34 @@ void main() {
|
||||
expect(match.group!.id, testGroup1.id);
|
||||
});
|
||||
|
||||
test('getMatchesByPlayer() works correctly', () async {
|
||||
await database.matchDao.addMatchesAsList(
|
||||
matches: [testMatch1, testMatch2],
|
||||
);
|
||||
|
||||
final matches = await database.matchDao.getMatchesByPlayer(
|
||||
playerId: testPlayer1.id,
|
||||
);
|
||||
|
||||
expect(matches, hasLength(1));
|
||||
expect(matches.first.id, testMatch2.id);
|
||||
expect(
|
||||
matches.first.players.any((p) => p.id == testPlayer1.id),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'getMatchesByPlayer() returns empty list for non-existent player',
|
||||
() async {
|
||||
final matches = await database.matchDao.getMatchesByPlayer(
|
||||
playerId: 'non-existing-player-id',
|
||||
);
|
||||
|
||||
expect(matches, isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
test('getMatchCount() works correctly', () async {
|
||||
var count = await database.matchDao.getMatchCount();
|
||||
expect(count, 0);
|
||||
|
||||
Reference in New Issue
Block a user