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.request_test; | 5 library shelf.request_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'; | 10 import 'package:shelf/shelf.dart'; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 }); | 271 }); |
272 | 272 |
273 test("throws if path isn't a path boundary", () { | 273 test("throws if path isn't a path boundary", () { |
274 var uri = Uri.parse('https://test.example.com/static/dir/file.html'); | 274 var uri = Uri.parse('https://test.example.com/static/dir/file.html'); |
275 var request = new Request('GET', uri, | 275 var request = new Request('GET', uri, |
276 handlerPath: '/static/', url: Uri.parse('dir/file.html')); | 276 handlerPath: '/static/', url: Uri.parse('dir/file.html')); |
277 | 277 |
278 expect(() => request.change(path: 'di'), throwsArgumentError); | 278 expect(() => request.change(path: 'di'), throwsArgumentError); |
279 }); | 279 }); |
280 }); | 280 }); |
| 281 |
| 282 test("allows the original request to be read", () { |
| 283 var request = _request(); |
| 284 var changed = request.change(); |
| 285 |
| 286 expect(request.read().toList(), completion(isEmpty)); |
| 287 expect(changed.read, throwsStateError); |
| 288 }); |
| 289 |
| 290 test("allows the changed request to be read", () { |
| 291 var request = _request(); |
| 292 var changed = request.change(); |
| 293 |
| 294 expect(changed.read().toList(), completion(isEmpty)); |
| 295 expect(request.read, throwsStateError); |
| 296 }); |
| 297 |
| 298 test("allows another changed request to be read", () { |
| 299 var request = _request(); |
| 300 var changed1 = request.change(); |
| 301 var changed2 = request.change(); |
| 302 |
| 303 expect(changed2.read().toList(), completion(isEmpty)); |
| 304 expect(changed1.read, throwsStateError); |
| 305 expect(request.read, throwsStateError); |
| 306 }); |
281 }); | 307 }); |
282 } | 308 } |
OLD | NEW |