Skip to content

Commit 6bd8459

Browse files
committed
test: Add example data for User
1 parent fd20b71 commit 6bd8459

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/example_data.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ StreamMessage streamMessage(
7171
});
7272
}
7373

74+
User user({int? userId, String? fullName}) {
75+
// The use of JSON here is convenient in order to delegate parts of the data
76+
// to helper functions. The main downside is that it loses static typing
77+
// of the properties as we're constructing the data. That's probably OK
78+
// because (a) this is only for tests; (b) the types do get checked
79+
// dynamically in the constructor, so any ill-typing won't propagate further.
80+
return User.fromJson({
81+
'user_id': userId ?? 123, // TODO generate example IDs
82+
'email': '[email protected]',
83+
'full_name': fullName ?? 'Full Name',
84+
'date_joined': '2023-04-28',
85+
'is_active': true,
86+
'is_owner': false,
87+
'is_admin': false,
88+
'is_guest': false,
89+
'is_billing_admin': false,
90+
'is_bot': false,
91+
'role': 400,
92+
'timezone': 'UTC',
93+
'avatar_version': 0,
94+
'profile_data': <String, dynamic>{},
95+
});
96+
}
97+
7498
// TODO example data for many more types
7599

76100
final InitialSnapshot initialSnapshot = InitialSnapshot(

0 commit comments

Comments
 (0)