Fixed tests
This commit is contained in:
@@ -26,18 +26,19 @@ class GameSession extends ChangeNotifier {
|
||||
int roundNumber;
|
||||
List<Round> roundList;
|
||||
|
||||
GameSession(
|
||||
{required this.id,
|
||||
required this.createdAt,
|
||||
required this.gameTitle,
|
||||
required this.players,
|
||||
required this.pointLimit,
|
||||
required this.caboPenalty,
|
||||
required this.isPointsLimitEnabled,
|
||||
this.isGameFinished = false,
|
||||
this.winner = '',
|
||||
this.roundNumber = 1,
|
||||
this.roundList = const []});
|
||||
GameSession({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.gameTitle,
|
||||
required this.players,
|
||||
required this.pointLimit,
|
||||
required this.caboPenalty,
|
||||
required this.isPointsLimitEnabled,
|
||||
this.isGameFinished = false,
|
||||
this.winner = '',
|
||||
this.roundNumber = 1,
|
||||
List<Round>? roundList,
|
||||
}) : roundList = roundList ?? [];
|
||||
|
||||
@override
|
||||
toString() {
|
||||
|
||||
@@ -19,9 +19,9 @@ class Round {
|
||||
required this.gameId,
|
||||
required this.roundNum,
|
||||
required this.caboPlayerIndex,
|
||||
this.kamikazePlayerIndex,
|
||||
required this.scores,
|
||||
required this.scoreUpdates,
|
||||
this.kamikazePlayerIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -8,6 +8,8 @@ void main() {
|
||||
const testKamikazePlayerIndex = 1;
|
||||
const testScores = [10, 20, 30];
|
||||
const testScoreUpdates = [5, 15, 25];
|
||||
const testRoundId = 'testRoundId';
|
||||
const testGameId = 'testGameId';
|
||||
|
||||
setUp(() {
|
||||
round = Round(
|
||||
@@ -32,8 +34,8 @@ void main() {
|
||||
|
||||
test('Constructor with null kamikazePlayerIndex', () {
|
||||
final roundWithoutKamikaze = Round(
|
||||
roundId: 'testRoundId',
|
||||
gameId: 'testGameId',
|
||||
roundId: testRoundId,
|
||||
gameId: testGameId,
|
||||
roundNum: testRoundNum,
|
||||
caboPlayerIndex: testCaboPlayerIndex,
|
||||
kamikazePlayerIndex: null,
|
||||
@@ -49,6 +51,8 @@ void main() {
|
||||
test('toJson() returns correct map', () {
|
||||
final jsonMap = round.toJson();
|
||||
|
||||
expect(jsonMap['roundId'], equals(testRoundId));
|
||||
expect(jsonMap['gameId'], equals(testGameId));
|
||||
expect(jsonMap['roundNum'], equals(testRoundNum));
|
||||
expect(jsonMap['caboPlayerIndex'], equals(testCaboPlayerIndex));
|
||||
expect(jsonMap['kamikazePlayerIndex'], equals(testKamikazePlayerIndex));
|
||||
@@ -58,6 +62,8 @@ void main() {
|
||||
|
||||
test('fromJson() creates correct Round object', () {
|
||||
final jsonMap = {
|
||||
'roundId': testRoundId,
|
||||
'gameId': testGameId,
|
||||
'roundNum': testRoundNum,
|
||||
'caboPlayerIndex': testCaboPlayerIndex,
|
||||
'kamikazePlayerIndex': testKamikazePlayerIndex,
|
||||
@@ -76,6 +82,8 @@ void main() {
|
||||
|
||||
test('fromJson() with null kamikazePlayerIndex', () {
|
||||
final jsonMap = {
|
||||
'roundId': testRoundId,
|
||||
'gameId': testGameId,
|
||||
'roundNum': testRoundNum,
|
||||
'caboPlayerIndex': testCaboPlayerIndex,
|
||||
'kamikazePlayerIndex': null,
|
||||
|
||||
Reference in New Issue
Block a user