Created
March 20, 2019 15:42
-
-
Save albertusdev/4d022a84225c2422c91a78611d373c7c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
group('User inputs valid form values', () { | |
const Duration delayedDuration = const Duration(milliseconds: 50); | |
setUp(() { | |
mockHttpClient = MockHttpClient(); | |
when(mockHttpClient.post<Map<String, dynamic>>(any, | |
data: anyNamed('data'))) | |
.thenAnswer((_) async { | |
await Future.delayed(delayedDuration); | |
return Future<Response<Map<String, dynamic>>>.value( | |
Response<Map<String, dynamic>>(data: <String, dynamic>{ | |
'token': 'token', | |
'user': UserFactory.constructDefaultUserJson() | |
})); | |
}); | |
}); | |
Future<void> chooseImageThenFillInAllFormThenScrollThenTapSubmitButton(WidgetTester tester) async { | |
await chooseImageFromImagePicker(tester); | |
await fillInAllFormWithValidInput(tester); | |
await scrollUntilBottom(tester); | |
final Finder submit = find.widgetWithText(InkWell, 'Register'); | |
await tester.tap(submit); | |
await tester.pump(); | |
} | |
testWidgets('Test submit status code 200 should redirect to another page', | |
(WidgetTester tester) async { | |
await tester.pumpWidget(makeTestableWidget(child: page)); | |
await chooseImageThenFillInAllFormThenScrollThenTapSubmitButton(tester); | |
await tester.pumpAndSettle(delayedDuration); | |
await tester.pumpAndSettle(); | |
expect(find.byType(DashboardPage), findsOneWidget); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment