Added tests for bug causing behaviour
This commit is contained in:
@@ -263,7 +263,7 @@ void main() {
|
|||||||
expect(matchCount, 0);
|
expect(matchCount, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Checking if match has winner works correclty', () async {
|
test('Checking if match has winner works correctly', () async {
|
||||||
await database.matchDao.addMatch(match: testMatch1);
|
await database.matchDao.addMatch(match: testMatch1);
|
||||||
await database.matchDao.addMatch(match: testMatchOnlyGroup);
|
await database.matchDao.addMatch(match: testMatchOnlyGroup);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:clock/clock.dart';
|
import 'package:clock/clock.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart' hide isNotNull;
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:game_tracker/data/db/database.dart';
|
import 'package:game_tracker/data/db/database.dart';
|
||||||
@@ -189,5 +189,33 @@ void main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Adding the same group to seperate matches works correctly', () async {
|
||||||
|
final match1 = Match(name: 'Match 1', group: testGroup1);
|
||||||
|
final match2 = Match(name: 'Match 2', group: testGroup1);
|
||||||
|
|
||||||
|
await Future.wait([
|
||||||
|
database.matchDao.addMatch(match: match1),
|
||||||
|
database.matchDao.addMatch(match: match2),
|
||||||
|
]);
|
||||||
|
|
||||||
|
final group1 = await database.groupMatchDao.getGroupOfMatch(
|
||||||
|
matchId: match1.id,
|
||||||
|
);
|
||||||
|
final group2 = await database.groupMatchDao.getGroupOfMatch(
|
||||||
|
matchId: match2.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(group1, isNotNull);
|
||||||
|
expect(group2, isNotNull);
|
||||||
|
|
||||||
|
final groups = [group1!, group2!];
|
||||||
|
for (final group in groups) {
|
||||||
|
expect(group.members.length, testGroup1.members.length);
|
||||||
|
expect(group.id, testGroup1.id);
|
||||||
|
expect(group.name, testGroup1.name);
|
||||||
|
expect(group.createdAt, testGroup1.createdAt);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:clock/clock.dart';
|
import 'package:clock/clock.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart' hide isNotNull;
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:game_tracker/data/db/database.dart';
|
import 'package:game_tracker/data/db/database.dart';
|
||||||
@@ -196,5 +196,42 @@ void main() {
|
|||||||
expect(player.createdAt, testPlayer.createdAt);
|
expect(player.createdAt, testPlayer.createdAt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'Adding the same player to seperate matches works correctly',
|
||||||
|
() async {
|
||||||
|
final playersList = [testPlayer1, testPlayer2, testPlayer3];
|
||||||
|
final match1 = Match(name: 'Match 1', players: playersList);
|
||||||
|
final match2 = Match(name: 'Match 2', players: playersList);
|
||||||
|
|
||||||
|
await Future.wait([
|
||||||
|
database.matchDao.addMatch(match: match1),
|
||||||
|
database.matchDao.addMatch(match: match2),
|
||||||
|
]);
|
||||||
|
|
||||||
|
final players1 = await database.playerMatchDao.getPlayersOfMatch(
|
||||||
|
matchId: match1.id,
|
||||||
|
);
|
||||||
|
final players2 = await database.playerMatchDao.getPlayersOfMatch(
|
||||||
|
matchId: match2.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(players1, isNotNull);
|
||||||
|
expect(players2, isNotNull);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
players1!.map((p) => p.id).toList(),
|
||||||
|
equals(players2!.map((p) => p.id).toList()),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
players1.map((p) => p.name).toList(),
|
||||||
|
equals(players2.map((p) => p.name).toList()),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
players1.map((p) => p.createdAt).toList(),
|
||||||
|
equals(players2.map((p) => p.createdAt).toList()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user