Skip to content

Commit 5967ff0

Browse files
committed
emoji_reaction test [nfc]: Move some setup code out next to similar code
1 parent c026fce commit 5967ff0

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

test/widgets/emoji_reaction_test.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,9 @@ void main() {
4242
Future<void> setupChipsInBox(WidgetTester tester, {
4343
required List<Reaction> reactions,
4444
double width = 245.0, // (seen in context on an iPhone 13 Pro)
45-
TextDirection textDirection = TextDirection.ltr,
4645
}) async {
4746
final message = eg.streamMessage(reactions: reactions);
4847

49-
final locale = switch (textDirection) {
50-
TextDirection.ltr => const Locale('en'),
51-
TextDirection.rtl => const Locale('ar'),
52-
};
53-
tester.platformDispatcher.localeTestValue = locale;
54-
tester.platformDispatcher.localesTestValue = [locale];
55-
addTearDown(tester.platformDispatcher.clearLocaleTestValue);
56-
addTearDown(tester.platformDispatcher.clearLocalesTestValue);
57-
5848
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
5949
child: Center(
6050
child: ColoredBox(
@@ -68,7 +58,6 @@ void main() {
6858
await tester.pumpAndSettle(); // global store, per-account store
6959

7060
final reactionChipsList = tester.element(find.byType(ReactionChipsList));
71-
check(Directionality.of(reactionChipsList)).equals(textDirection);
7261
check(reactionChipsList).size.isNotNull().width.equals(width);
7362
}
7463

@@ -106,6 +95,15 @@ void main() {
10695
tester.platformDispatcher.textScaleFactorTestValue = textScaleFactor;
10796
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
10897

98+
final locale = switch (textDirection) {
99+
TextDirection.ltr => const Locale('en'),
100+
TextDirection.rtl => const Locale('ar'),
101+
};
102+
tester.platformDispatcher.localeTestValue = locale;
103+
tester.platformDispatcher.localesTestValue = [locale];
104+
addTearDown(tester.platformDispatcher.clearLocaleTestValue);
105+
addTearDown(tester.platformDispatcher.clearLocalesTestValue);
106+
109107
await prepare();
110108

111109
await store.addUsers(users);
@@ -126,7 +124,10 @@ void main() {
126124
..statusCode = HttpStatus.ok
127125
..content = kSolidBlueAvatar;
128126

129-
await setupChipsInBox(tester, textDirection: textDirection, reactions: reactions);
127+
await setupChipsInBox(tester, reactions: reactions);
128+
129+
final reactionChipsList = tester.element(find.byType(ReactionChipsList));
130+
check(Directionality.of(reactionChipsList)).equals(textDirection);
130131

131132
// TODO(upstream) Do these in an addTearDown, once we can:
132133
// https://github.com/flutter/flutter/issues/123189

0 commit comments

Comments
 (0)