I built this code just to get tests running I ported from TypeScript to Dart
import 'dart:async' show Future;
import 'dart:html' show HttpRequest;
import 'dart:convert' show JSON;
class Http {
Future<Response> get(String uri) async {
final HttpRequest req = new HttpRequest()..open('GET', uri);
await req.onLoadEnd.first;
req.send();
return new Response(req);
}
}
class Response {
final HttpRequest request;
Response(this.request);
String text() => request.responseText;
dynamic json() => JSON.decode(request.response);
}
It has only a `get()` method, but other methods are quite similar.
You can get inspiration from the TypeScript source about what features to add.
For mocking, just extend it `class MockHttp extends Http {` and override the methods with dummy actions.