1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-12 07:48:55 +00:00

Update mockito in form_app (#904)

This commit is contained in:
John Ryan
2021-10-05 04:49:11 -07:00
committed by GitHub
parent 3de664f9e7
commit 9a9f0210b7
6 changed files with 77 additions and 23 deletions

View File

@@ -9,12 +9,14 @@ import 'package:mockito/mockito.dart';
class MockClient extends Mock implements http.Client {
MockClient() {
when(post('https://example.com/signin', body: anyNamed('body')))
when(post('https://example.com/signin',
body: anyNamed('body'), headers: anyNamed('headers')))
.thenAnswer((answering) {
dynamic body = answering.namedArguments[const Symbol('body')];
if (body != null && body is String) {
var decodedJson = json.decode(body) as Map<String, String>;
var decodedJson = Map<String, dynamic>.from(
json.decode(body) as Map<String, dynamic>);
if (decodedJson['email'] == 'root' &&
decodedJson['password'] == 'password') {