Last active
April 15, 2020 16:33
-
-
Save hyochan/642cdff6e5bac0027723604df6f9ee9e to your computer and use it in GitHub Desktop.
flutter_localized_example/test/widget_test.dart
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:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:localized_app_example/widgets/my_widget.dart' show MyWidget; | |
Widget makeTestableWidget({ Widget child }) { | |
return MediaQuery( | |
data: MediaQueryData(), | |
child: MaterialApp( | |
localizationsDelegates: [ | |
LocalizationDelegate(isTest: true), | |
GlobalMaterialLocalizations.delegate, | |
GlobalWidgetsLocalizations.delegate, | |
], | |
home: child, | |
), | |
); | |
}; | |
void main() { | |
testWidgets("Widget", (WidgetTester tester) async{ | |
await tester.pumpWidget(makeTestableWidget(child: MyWidget())); | |
await tester.pumpAndSettle(); | |
var findByText = find.byType(Text); | |
print(findByText.evaluate()); | |
expect(findByText.evaluate().isEmpty, false); | |
expect(find.text('LOADING') findsOneWidget); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment