Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Unified Diff: pkg/shelf/test/response_test.dart

Issue 256753004: pkg/shelf: change helper method on Request and Response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nevermind Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/test/request_test.dart ('k') | pkg/shelf/test/shelf_io_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/response_test.dart
diff --git a/pkg/shelf/test/response_test.dart b/pkg/shelf/test/response_test.dart
index 9ee47c5f93360f8a62b82680a7bdd597ff12be3e..86652c78c7b30ea990948f75fcbcb1117882cfd7 100644
--- a/pkg/shelf/test/response_test.dart
+++ b/pkg/shelf/test/response_test.dart
@@ -7,62 +7,23 @@ library shelf.response_test;
import 'dart:async';
import 'dart:convert';
-import 'package:shelf/shelf.dart';
+import 'package:shelf/shelf.dart' hide Request;
import 'package:unittest/unittest.dart';
-void main() {
- group("readAsString", () {
- test("supports a null body", () {
- var response = new Response(200);
- expect(response.readAsString(), completion(equals("")));
- });
+import 'test_util.dart';
- test("supports a String body", () {
+void main() {
+ group("supports a String body", () {
+ test("readAsString", () {
var response = new Response.ok("hello, world");
expect(response.readAsString(), completion(equals("hello, world")));
});
- test("supports a Stream<List<int>> body", () {
- var controller = new StreamController();
- var response = new Response.ok(controller.stream);
- expect(response.readAsString(), completion(equals("hello, world")));
+ test("read", () {
+ var helloWorldBytes = new List.from(HELLO_BYTES)..addAll(WORLD_BYTES);
- controller.add([104, 101, 108, 108, 111, 44]);
- return new Future(() {
- controller
- ..add([32, 119, 111, 114, 108, 100])
- ..close();
- });
- });
- });
-
- group("read", () {
- test("supports a null body", () {
- var response = new Response(200);
- expect(response.read().toList(), completion(isEmpty));
- });
-
- test("supports a String body", () {
var response = new Response.ok("hello, world");
- expect(response.read().toList(), completion(equals([[
- 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100
- ]])));
- });
-
- test("supports a Stream<List<int>> body", () {
- var controller = new StreamController();
- var response = new Response.ok(controller.stream);
- expect(response.read().toList(), completion(equals([
- [104, 101, 108, 108, 111, 44],
- [32, 119, 111, 114, 108, 100]
- ])));
-
- controller.add([104, 101, 108, 108, 111, 44]);
- return new Future(() {
- controller
- ..add([32, 119, 111, 114, 108, 100])
- ..close();
- });
+ expect(response.read().toList(), completion(equals([helloWorldBytes])));
});
});
@@ -157,4 +118,29 @@ void main() {
}).lastModified, equals(DateTime.parse("1994-11-06 08:49:37z")));
});
});
+
+ group('change', () {
+ test('with no arguments returns instance with equal values', () {
+ var controller = new StreamController();
+
+ var request = new Response(345, body: 'hèllo, world', encoding: LATIN1,
+ headers: {'header1': 'header value 1'},
+ context: {'context1': 'context value 1'});
+
+ var copy = request.change();
+
+ expect(copy.statusCode, request.statusCode);
+ expect(copy.readAsString(), completion('hèllo, world'));
+ expect(copy.headers, same(request.headers));
+ expect(copy.encoding, request.encoding);
+ expect(copy.context, same(request.context));
+
+ controller.add(HELLO_BYTES);
+ return new Future(() {
+ controller
+ ..add(WORLD_BYTES)
+ ..close();
+ });
+ });
+ });
}
« no previous file with comments | « pkg/shelf/test/request_test.dart ('k') | pkg/shelf/test/shelf_io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698