From d173dd75fb46d4fb84145cc4307281639bf8f95b Mon Sep 17 00:00:00 2001 From: thosakwe Date: Tue, 28 Mar 2017 22:28:58 -0400 Subject: [PATCH] 1.0.4 --- README.md | 2 +- lib/src/client.dart | 12 ++++++------ pubspec.yaml | 2 +- test/simple_test.dart | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) 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');