This commit is contained in:
thosakwe 2017-03-28 22:28:58 -04:00
parent 6128daf5d6
commit d173dd75fb
4 changed files with 25 additions and 8 deletions

View file

@ -1,5 +1,5 @@
# angel_test
[![version 1.0.3](https://img.shields.io/badge/pub-1.0.3-brightgreen.svg)](https://pub.dartlang.org/packages/angel_test)
[![version 1.0.4](https://img.shields.io/badge/pub-1.0.4-brightgreen.svg)](https://pub.dartlang.org/packages/angel_test)
[![build status](https://travis-ci.org/angel-dart/test.svg)](https://travis-ci.org/angel-dart/test)
Testing utility library for the Angel framework.

View file

@ -104,7 +104,9 @@ class TestClient extends client.BaseAngelClient {
await server.handleRequest(rq);
var rs = rq.response;
session.addAll(rq.session);
session
..clear()
..addAll(rq.session);
Map<String, String> extractedHeaders = {};
@ -157,9 +159,7 @@ class TestClient extends client.BaseAngelClient {
{Type type, client.AngelDeserializer deserializer}) {
String uri = path.toString().replaceAll(_straySlashes, "");
return _services.putIfAbsent(
uri,
() => new _MockService(this, '$basePath/$uri',
deserializer: deserializer));
uri, () => new _MockService(this, uri, deserializer: deserializer));
}
}
@ -176,8 +176,8 @@ class _MockService extends client.BaseAngelService {
request.headers['Authorization'] = 'Bearer ${app.authToken}';
}
return _app.send(request.method, request.url, request.headers,
request.finalize());
return _app.send(
request.method, request.url, request.headers, request.finalize());
}
}

View file

@ -2,7 +2,7 @@ author: "Tobe O <thosakwe@gmail.com>"
description: "Testing utility library for the Angel framework."
homepage: "https://github.com/angel-dart/test.git"
name: "angel_test"
version: "1.0.3"
version: "1.0.4"
dependencies:
angel_client: "^1.0.0"
angel_framework: "^1.0.0-dev"

View file

@ -33,6 +33,9 @@ main() {
..use(
'/foo',
new AnonymousService(
index: ([params]) async => [
{'michael': 'jackson'}
],
create: (data, [params]) async => {'foo': 'bar'}));
var ws = new AngelWebSocket();
@ -96,6 +99,20 @@ main() {
})));
});
group('service', () {
test('index', () async {
var foo = client.service('foo');
var result = await foo.index();
expect(result, [{'michael': 'jackson'}]);
});
test('index', () async {
var foo = client.service('foo');
var result = await foo.create({});
expect(result, {'foo': 'bar'});
});
});
test('websocket', () async {
var ws = await client.websocket();
var foo = ws.service('foo');