Last active
April 15, 2020 16:34
-
-
Save hyochan/9aa7ede3af173ed536158f97d970031b to your computer and use it in GitHub Desktop.
localized_widget_test_legacy.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(), | |
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