| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library shelf.response_test; | 5 library shelf.response_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:shelf/shelf.dart' hide Request; | 10 import 'package:shelf/shelf.dart' hide Request; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 expect(copy.encoding, request.encoding); | 105 expect(copy.encoding, request.encoding); |
| 106 expect(copy.context, same(request.context)); | 106 expect(copy.context, same(request.context)); |
| 107 | 107 |
| 108 controller.add(HELLO_BYTES); | 108 controller.add(HELLO_BYTES); |
| 109 return new Future(() { | 109 return new Future(() { |
| 110 controller | 110 controller |
| 111 ..add(WORLD_BYTES) | 111 ..add(WORLD_BYTES) |
| 112 ..close(); | 112 ..close(); |
| 113 }); | 113 }); |
| 114 }); | 114 }); |
| 115 |
| 116 |
| 117 test("allows the original response to be read", () { |
| 118 var response = new Response.ok(null); |
| 119 var changed = response.change(); |
| 120 |
| 121 expect(response.read().toList(), completion(isEmpty)); |
| 122 expect(changed.read, throwsStateError); |
| 123 }); |
| 124 |
| 125 test("allows the changed response to be read", () { |
| 126 var response = new Response.ok(null); |
| 127 var changed = response.change(); |
| 128 |
| 129 expect(changed.read().toList(), completion(isEmpty)); |
| 130 expect(response.read, throwsStateError); |
| 131 }); |
| 132 |
| 133 test("allows another changed response to be read", () { |
| 134 var response = new Response.ok(null); |
| 135 var changed1 = response.change(); |
| 136 var changed2 = response.change(); |
| 137 |
| 138 expect(changed2.read().toList(), completion(isEmpty)); |
| 139 expect(changed1.read, throwsStateError); |
| 140 expect(response.read, throwsStateError); |
| 141 }); |
| 115 }); | 142 }); |
| 116 } | 143 } |
| OLD | NEW |