Skip to content

Commit

Permalink
test(llc): fix user, own_user tests
Browse files Browse the repository at this point in the history
Signed-off-by: xsahil03x <[email protected]>
  • Loading branch information
xsahil03x committed May 20, 2022
1 parent 180e447 commit 89a3d09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/stream_chat/lib/src/core/models/own_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class OwnUser extends User {
factory OwnUser.fromUser(User user) => OwnUser(
id: user.id,
role: user.role,
name: user.name,
// Using extraData value in order to not use id as name.
name: user.extraData['name'] as String?,
image: user.image,
createdAt: user.createdAt,
updatedAt: user.updatedAt,
Expand Down Expand Up @@ -78,7 +79,10 @@ class OwnUser extends User {
OwnUser(
id: id ?? this.id,
role: role ?? this.role,
name: name ?? extraData?['name'] as String? ?? this.name,
name: name ??
extraData?['name'] as String? ??
// Using extraData value in order to not use id as name.
this.extraData['name'] as String?,
image: image ?? extraData?['image'] as String? ?? this.image,
banned: banned ?? this.banned,
banExpires: banExpires ?? this.banExpires,
Expand All @@ -103,7 +107,8 @@ class OwnUser extends User {
return copyWith(
id: other.id,
role: other.role,
name: other.name,
// Using extraData value in order to not use id as name.
name: other.extraData['name'] as String?,
image: other.image,
banned: other.banned,
channelMutes: other.channelMutes,
Expand Down
5 changes: 4 additions & 1 deletion packages/stream_chat/lib/src/core/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ class User extends Equatable {
User(
id: id ?? this.id,
role: role ?? this.role,
name: name ?? extraData?['name'] as String? ?? this.name,
name: name ??
extraData?['name'] as String? ??
// Using extraData value in order to not use id as name.
this.extraData['name'] as String?,
image: image ?? extraData?['image'] as String? ?? this.image,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat/test/src/client/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@ void main() {
});

test(
'''setting the `currentUser` should also compute and update the unreadCounts''',
'setting the `currentUser` should also compute and update the unreadCounts',
() {
final state = client.state;
final initialUser = OwnUser.fromUser(user);
Expand Down

0 comments on commit 89a3d09

Please sign in to comment.