-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4914479
commit a79e2c7
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); | ||
}); | ||
} |