fix tests

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-04-19 17:43:11 +05:30
parent af135ecb9c
commit 07196eab96
4 changed files with 339 additions and 139 deletions
@@ -12,11 +12,11 @@ class Reaction {
this.messageId,
DateTime? createdAt,
required this.type,
required this.user,
this.user,
String? userId,
this.score = 0,
this.extraData,
}) : userId = userId ?? user.id,
}) : userId = userId ?? user?.id,
createdAt = createdAt ?? DateTime.now();
/// Create a new instance from a json
@@ -38,7 +38,7 @@ class Reaction {
/// The user that sent the reaction
@JsonKey(includeIfNull: false, toJson: Serialization.readOnly)
final User user;
final User? user;
/// The score of the reaction (ie. number of reactions sent)
@JsonKey(defaultValue: 0)
@@ -13,7 +13,9 @@ Reaction _$ReactionFromJson(Map<String, dynamic> json) {
? null
: DateTime.parse(json['created_at'] as String),
type: json['type'] as String,
user: User.fromJson(json['user'] as Map<String, dynamic>),
user: json['user'] == null
? null
: User.fromJson(json['user'] as Map<String, dynamic>),
userId: json['user_id'] as String?,
score: json['score'] as int? ?? 0,
extraData: json['extra_data'] as Map<String, dynamic>?,