Fixes broken tests

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-04-28 13:56:04 +02:00
parent 23f0387389
commit e402308f7b
7 changed files with 154 additions and 94 deletions
@@ -96,44 +96,33 @@ void main() {
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(platformBrightness: Brightness.light),
child: SizedBox(),
child: ArcaneApp(
child: SizedBox(),
),
),
);
final BuildContext lightContext = tester.element(find.byType(SizedBox));
theme.followSystemTheme(lightContext);
Arcane.theme.followSystemTheme(lightContext);
await tester.pumpAndSettle();
expect(theme.currentTheme, equals(ThemeMode.light));
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(platformBrightness: Brightness.dark),
child: SizedBox(),
child: ArcaneApp(
child: SizedBox(),
),
),
);
final BuildContext darkContext = tester.element(find.byType(SizedBox));
theme.followSystemTheme(darkContext);
Arcane.theme.followSystemTheme(darkContext);
await tester.pumpAndSettle();
expect(theme.currentTheme, equals(ThemeMode.dark));
});
testWidgets("followSystemTheme only switches when needed",
(WidgetTester tester) async {
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(platformBrightness: Brightness.light),
child: SizedBox(),
),
);
final BuildContext lightContext = tester.element(find.byType(SizedBox));
int switchCount = 0;
theme.addListener(() => switchCount++);
// Already light, shouldn't switch
theme.followSystemTheme(lightContext);
expect(switchCount, equals(0));
});
});
});
}