Created
May 10, 2022 19:27
-
-
Save Kirpal/34b509de02747fc016d2df13030bb89f to your computer and use it in GitHub Desktop.
Alchemist Localizations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:alchemist/alchemist.dart'; | |
import 'package:flutter/widgets.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:mocktail_image_network/mocktail_image_network.dart'; | |
class FakeLocalizations { | |
String get exampleString => 'EXAMPLE STRING'; | |
} | |
class FakeLocalizationsDelegate | |
extends LocalizationsDelegate<FakeLocalizations> { | |
const FakeLocalizationsDelegate(); | |
@override | |
bool isSupported(Locale locale) => true; | |
@override | |
Future<FakeLocalizations> load(Locale locale) => | |
Future.value(FakeLocalizations()); | |
@override | |
bool shouldReload(FakeLocalizationsDelegate old) => false; | |
} | |
void main() { | |
group('smoke test', () { | |
goldenTest( | |
'succeeds with a network image', | |
fileName: 'network_image_smoke_test', | |
pumpWidget: (tester, widget) async { | |
await mockNetworkImages(() => tester.pumpWidget(widget)); | |
}, | |
builder: () => Localizations( | |
locale: const Locale('en'), | |
delegates: const [ | |
DefaultWidgetsLocalizations.delegate, | |
FakeLocalizationsDelegate(), | |
], | |
child: Builder( | |
builder: (context) => Text( | |
Localizations.of<FakeLocalizations>(context, FakeLocalizations)! | |
.exampleString, | |
), | |
), | |
), | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment