From 16f0ad0db613dc36b1bd90c16acc76bdd3a60cbf Mon Sep 17 00:00:00 2001 From: thosakwe Date: Sat, 25 Mar 2017 00:12:21 -0400 Subject: [PATCH] Going --- lib/src/client.dart | 12 ++++++++++++ pubspec.yaml | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index 14321bc2..0a64a090 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:angel_client/io.dart' as client; import 'package:angel_framework/angel_framework.dart'; +import 'package:mock_request/mock_request.dart'; import 'package:uuid/uuid.dart'; final Uuid _uuid = new Uuid(); @@ -42,6 +43,17 @@ Future connectTo(Angel app, return client; } +Future mock(Angel app, String method, Uri uri, + {Iterable cookies: const [], + Map headers: const {}}) async { + var rq = new MockHttpRequest(method, uri); + rq.cookies.addAll(cookies ?? []); + headers.forEach(rq.headers.add); + await rq.close(); + await app.handleRequest(rq); + return rq.response; +} + /// Interacts with an Angel server. class TestClient extends client.Rest { final HttpServer server; diff --git a/pubspec.yaml b/pubspec.yaml index d68b97f9..c7f542d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,6 +8,7 @@ dependencies: angel_framework: "^1.0.0-dev" http: "^0.11.3+9" matcher: "^0.12.0+2" + mock_request: ^1.0.0 uuid: "^0.5.3" dev_dependencies: test: "^0.12.17+2"