How can I write a unit test to return the status code of a response that is part of a Future? I got this far before getting stuck
import 'package:http/http.dart' as http;
test( "test future", (){
Future<Response> future = http.get( "http://www.google.com");
expect( future, completion( equals( ( Response e)=>(e.statusCode ), 200)));
});
This fails with the message
FAIL: test future Expected: <Closure: (Response) => dynamic>
Actual: <Instance of 'Response'>
I then tried
solo_test( "test response status", (){
http.get( "http://www.google.com").then( expectAsync0((response)=>expect( response.statusCode,200)));
});
Which fails with the message
Test failed: Caught type '() => dynamic' is not a subtype of type '(dynamic) => dynamic' of 'f'.
Seems to work this way