| 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 | 8 |
| 9 import 'package:shelf/shelf.dart'; | 9 import 'package:shelf/shelf.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import 'test_util.dart'; | 12 import 'test_util.dart'; |
| 13 | 13 |
| 14 Request _request([Map<String, String> headers, Stream<List<int>> body]) { | 14 Request _request([Map<String, String> headers, Stream<List<int>> body, |
| 15 return new Request("GET", LOCALHOST_URI, headers: headers, body: body); | 15 Map<String, Object> context]) { |
| 16 return new Request("GET", LOCALHOST_URI, headers: headers, body: body, |
| 17 context: context); |
| 16 } | 18 } |
| 17 | 19 |
| 18 void main() { | 20 void main() { |
| 19 group('constructor', () { | 21 group('constructor', () { |
| 20 test('protocolVersion defaults to "1.1"', () { | 22 test('protocolVersion defaults to "1.1"', () { |
| 21 var request = new Request('GET', LOCALHOST_URI); | 23 var request = new Request('GET', LOCALHOST_URI); |
| 22 expect(request.protocolVersion, '1.1'); | 24 expect(request.protocolVersion, '1.1'); |
| 23 }); | 25 }); |
| 24 | 26 |
| 25 test('provide non-default protocolVersion', () { | 27 test('provide non-default protocolVersion', () { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 ]))); | 173 ]))); |
| 172 | 174 |
| 173 controller.add([104, 101, 108, 108, 111, 44]); | 175 controller.add([104, 101, 108, 108, 111, 44]); |
| 174 return new Future(() { | 176 return new Future(() { |
| 175 controller | 177 controller |
| 176 ..add([32, 119, 111, 114, 108, 100]) | 178 ..add([32, 119, 111, 114, 108, 100]) |
| 177 ..close(); | 179 ..close(); |
| 178 }); | 180 }); |
| 179 }); | 181 }); |
| 180 }); | 182 }); |
| 183 |
| 184 group("context", () { |
| 185 test("is correctly populated", () { |
| 186 expect(_request({ |
| 187 'content-type': 'text/plain' |
| 188 }, null, { |
| 189 'my-param' : 42 |
| 190 }).context['my-param'], equals(42)); |
| 191 }); |
| 192 }); |
| 181 } | 193 } |
| OLD | NEW |