diff --git a/README.md b/README.md index 3d21b948..6219b4b8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/src/client.dart b/lib/src/client.dart index c71d2cad..62301ff8 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -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 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()); } } diff --git a/pubspec.yaml b/pubspec.yaml index fd430aa2..d53ce935 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ author: "Tobe O " 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" diff --git a/test/simple_test.dart b/test/simple_test.dart index afe9ac4b..6fc1f6df 100644 --- a/test/simple_test.dart +++ b/test/simple_test.dart @@ -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');