Commit d6056e50 authored by justin's avatar justin

test fix

parent c1e77230
......@@ -137,7 +137,7 @@ void main() {
expect(find.text('Y', skipOffstage: false), findsNothing);
});
//
testWidgets('Navigator.of fails gracefully when not found in context',
testWidgets('Navigator.of gracefully when not found in context',
(WidgetTester tester) async {
const Key targetKey = Key('foo');
dynamic exception;
......@@ -148,7 +148,13 @@ void main() {
},
);
await tester.pumpWidget(widget);
await tester.pump(Duration(seconds: 1));
await tester.tap(find.byKey(targetKey));
await tester.pump(Duration(seconds: 1));
expect(exception, isInstanceOf<FlutterError>());
expect('$exception',
startsWith('Navigator operation requested with a context'));
......
......@@ -47,7 +47,7 @@ void main() {
group('Try to get the BoostPageRoute in the ancestor node', () {
testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.of(context)` method',
'obtain BoostPageRoute through the BoostPageRoute.of(context) method',
(WidgetTester tester) async {
dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod;
......@@ -74,13 +74,15 @@ void main() {
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect(boostPageRoute, boostPageRouteFindByOfMethod);
});
testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.of(context)` method, '
'try to find BoostPageRoute through the BoostPageRoute.of(context) method, '
'but it doesn\'t exist, the method should throw an Exception',
(WidgetTester tester) async {
dynamic contextCache;
......@@ -102,12 +104,13 @@ void main() {
),
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(() => BoostPageRoute.of<dynamic>(contextCache), throwsException);
});
testWidgets(
'obtain BoostPageRoute through the `BoostPageRoute.tryOf(context)` method',
'obtain BoostPageRoute through the BoostPageRoute.tryOf(context) method',
(WidgetTester tester) async {
dynamic boostPageRoute;
dynamic boostPageRouteFindByOfMethod;
......@@ -134,6 +137,7 @@ void main() {
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
// The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
......@@ -142,7 +146,7 @@ void main() {
});
testWidgets(
'try to find BoostPageRoute through the `BoostPageRoute.tryOf(context)` method, '
'try to find BoostPageRoute through the BoostPageRoute.tryOf(context) method, '
'but it doesn\'t exist, the method should return null',
(WidgetTester tester) async {
dynamic boostPageRouteFindByOfMethod;
......@@ -168,6 +172,7 @@ void main() {
);
await tester.tap(find.byType(FloatingActionButton));
await tester.pump(Duration(seconds: 1));
expect(boostPageRouteFindByOfMethod, null);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment