Skip to content

Commit

Permalink
test: answer model
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgalarraga committed Apr 17, 2024
1 parent 4914479 commit a79e2c7
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions api/packages/game_domain/test/src/models/answer_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ignore_for_file: prefer_const_constructors

import 'package:game_domain/game_domain.dart';
import 'package:test/test.dart';

void main() {
group('Answer', () {
test('creates correct json object from Answer object', () {
final answer = Answer(id: 'id', answer: 'answer', section: Point(1, 2));
final json = answer.toJson();

expect(
json,
equals({
'id': 'id',
'answer': 'answer',
'section': {'x': 1, 'y': 2},
}),
);
});

test('creates correct Answer object from json object', () {
final json = {
'id': 'id',
'answer': 'answer',
'section': {'x': 1, 'y': 2},
};
final answer = Answer.fromJson(json);
expect(
answer,
equals(
Answer(id: 'id', answer: 'answer', section: Point(1, 2)),
),
);
});

test('supports equality', () {
final firstAnswer = Answer(
id: 'id',
answer: 'answer',
section: Point(1, 2),
);
final secondAnswer = Answer(
id: 'id',
answer: 'answer',
section: Point(1, 2),
);
expect(firstAnswer, equals(secondAnswer));
});
});
}

0 comments on commit a79e2c7

Please sign in to comment.