Skip to content

Commit 221ba81

Browse files
committed
test [nfc]: Move eg.customProfileField out from one test file
1 parent a578947 commit 221ba81

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

test/example_data.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,24 @@ GetServerSettingsResult serverSettings({
131131
);
132132
}
133133

134+
CustomProfileField customProfileField(
135+
int id,
136+
CustomProfileFieldType type, {
137+
int? order,
138+
bool? displayInProfileSummary,
139+
String? fieldData,
140+
}) {
141+
return CustomProfileField(
142+
id: id,
143+
type: type,
144+
order: order ?? id,
145+
name: 'field$id',
146+
hint: 'hint$id',
147+
fieldData: fieldData ?? '',
148+
displayInProfileSummary: displayInProfileSummary ?? false,
149+
);
150+
}
151+
134152
ServerEmojiData _immutableServerEmojiData({
135153
required Map<String, List<String>> codeToNames}) {
136154
return ServerEmojiData(

test/widgets/profile_test.dart

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,6 @@ Future<void> setupPage(WidgetTester tester, {
7070
await tester.pumpAndSettle();
7171
}
7272

73-
CustomProfileField mkCustomProfileField(
74-
int id,
75-
CustomProfileFieldType type, {
76-
int? order,
77-
bool? displayInProfileSummary,
78-
String? fieldData,
79-
}) {
80-
return CustomProfileField(
81-
id: id,
82-
type: type,
83-
order: order ?? id,
84-
name: 'field$id',
85-
hint: 'hint$id',
86-
fieldData: fieldData ?? '',
87-
displayInProfileSummary: displayInProfileSummary ?? false,
88-
);
89-
}
90-
9173
void main() {
9274
TestZulipBinding.ensureInitialized();
9375

@@ -153,16 +135,16 @@ void main() {
153135
],
154136
pageUserId: 1,
155137
customProfileFields: [
156-
mkCustomProfileField(0, CustomProfileFieldType.shortText),
157-
mkCustomProfileField(1, CustomProfileFieldType.longText),
158-
mkCustomProfileField(2, CustomProfileFieldType.choice,
138+
eg.customProfileField(0, CustomProfileFieldType.shortText),
139+
eg.customProfileField(1, CustomProfileFieldType.longText),
140+
eg.customProfileField(2, CustomProfileFieldType.choice,
159141
fieldData: '{"x": {"text": "choiceValue", "order": "1"}}'),
160-
mkCustomProfileField(3, CustomProfileFieldType.date),
161-
mkCustomProfileField(4, CustomProfileFieldType.link),
162-
mkCustomProfileField(5, CustomProfileFieldType.user),
163-
mkCustomProfileField(6, CustomProfileFieldType.externalAccount,
142+
eg.customProfileField(3, CustomProfileFieldType.date),
143+
eg.customProfileField(4, CustomProfileFieldType.link),
144+
eg.customProfileField(5, CustomProfileFieldType.user),
145+
eg.customProfileField(6, CustomProfileFieldType.externalAccount,
164146
fieldData: '{"subtype": "external1"}'),
165-
mkCustomProfileField(7, CustomProfileFieldType.pronouns),
147+
eg.customProfileField(7, CustomProfileFieldType.pronouns),
166148
], realmDefaultExternalAccounts: {
167149
'external1': RealmDefaultExternalAccount(
168150
name: 'external1',
@@ -207,7 +189,7 @@ void main() {
207189
await setupPage(tester,
208190
users: [user],
209191
pageUserId: user.userId,
210-
customProfileFields: [mkCustomProfileField(0, CustomProfileFieldType.link)],
192+
customProfileFields: [eg.customProfileField(0, CustomProfileFieldType.link)],
211193
);
212194

213195
await tester.tap(find.text(testUrl));
@@ -226,7 +208,7 @@ void main() {
226208
users: [user],
227209
pageUserId: user.userId,
228210
customProfileFields: [
229-
mkCustomProfileField(0, CustomProfileFieldType.externalAccount,
211+
eg.customProfileField(0, CustomProfileFieldType.externalAccount,
230212
fieldData: '{"subtype": "external1"}')
231213
],
232214
realmDefaultExternalAccounts: {
@@ -258,7 +240,7 @@ void main() {
258240
await setupPage(tester,
259241
users: users,
260242
pageUserId: 1,
261-
customProfileFields: [mkCustomProfileField(0, CustomProfileFieldType.user)],
243+
customProfileFields: [eg.customProfileField(0, CustomProfileFieldType.user)],
262244
navigatorObserver: testNavObserver,
263245
);
264246

@@ -279,7 +261,7 @@ void main() {
279261
await setupPage(tester,
280262
users: users,
281263
pageUserId: 1,
282-
customProfileFields: [mkCustomProfileField(0, CustomProfileFieldType.user)],
264+
customProfileFields: [eg.customProfileField(0, CustomProfileFieldType.user)],
283265
);
284266

285267
final textFinder = find.text('(unknown user)');
@@ -310,7 +292,7 @@ void main() {
310292
users: users,
311293
mutedUserIds: [2],
312294
pageUserId: 1,
313-
customProfileFields: [mkCustomProfileField(0, CustomProfileFieldType.user)]);
295+
customProfileFields: [eg.customProfileField(0, CustomProfileFieldType.user)]);
314296

315297
check(find.text('Muted user')).findsOne();
316298
check(mutedAvatarFinder(2)).findsOne();
@@ -335,7 +317,7 @@ void main() {
335317
await setupPage(tester,
336318
users: users,
337319
pageUserId: 1,
338-
customProfileFields: [mkCustomProfileField(0, CustomProfileFieldType.user)],
320+
customProfileFields: [eg.customProfileField(0, CustomProfileFieldType.user)],
339321
);
340322

341323
final avatars = tester.widgetList<Avatar>(find.byType(Avatar));
@@ -358,16 +340,16 @@ void main() {
358340

359341
await setupPage(tester, users: [user, user2], pageUserId: user.userId,
360342
customProfileFields: [
361-
mkCustomProfileField(0, CustomProfileFieldType.shortText),
362-
mkCustomProfileField(1, CustomProfileFieldType.longText),
363-
mkCustomProfileField(2, CustomProfileFieldType.choice,
343+
eg.customProfileField(0, CustomProfileFieldType.shortText),
344+
eg.customProfileField(1, CustomProfileFieldType.longText),
345+
eg.customProfileField(2, CustomProfileFieldType.choice,
364346
fieldData: '{"x": {"text": "$longString", "order": "1"}}'),
365347
// no [CustomProfileFieldType.date] because those can't be made long
366-
mkCustomProfileField(3, CustomProfileFieldType.link),
367-
mkCustomProfileField(4, CustomProfileFieldType.user),
368-
mkCustomProfileField(5, CustomProfileFieldType.externalAccount,
348+
eg.customProfileField(3, CustomProfileFieldType.link),
349+
eg.customProfileField(4, CustomProfileFieldType.user),
350+
eg.customProfileField(5, CustomProfileFieldType.externalAccount,
369351
fieldData: '{"subtype": "external1"}'),
370-
mkCustomProfileField(6, CustomProfileFieldType.pronouns),
352+
eg.customProfileField(6, CustomProfileFieldType.pronouns),
371353
], realmDefaultExternalAccounts: {
372354
'external1': RealmDefaultExternalAccount(
373355
name: 'external1',

0 commit comments

Comments
 (0)