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'; | 10 import 'package:shelf/shelf.dart'; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 test("is null without a content-length header", () { | 224 test("is null without a content-length header", () { |
225 expect(new Response.ok("okay!").contentLength, isNull); | 225 expect(new Response.ok("okay!").contentLength, isNull); |
226 }); | 226 }); |
227 | 227 |
228 test("comes from the content-length header", () { | 228 test("comes from the content-length header", () { |
229 expect(new Response.ok("okay!", headers: { | 229 expect(new Response.ok("okay!", headers: { |
230 'content-length': '42' | 230 'content-length': '42' |
231 }).contentLength, equals(42)); | 231 }).contentLength, equals(42)); |
232 }); | 232 }); |
233 }); | 233 }); |
| 234 |
| 235 |
| 236 group("context", () { |
| 237 test("are correctly populated in ok", () { |
| 238 expect(new Response.ok("okay!", headers: {}, context: { |
| 239 'my-param' : 42 |
| 240 }).context['my-param'], equals(42)); |
| 241 }); |
| 242 |
| 243 test("are correctly populated in forbidden", () { |
| 244 expect(new Response.forbidden("okay!", headers: {}, context: { |
| 245 'my-param' : 42 |
| 246 }).context['my-param'], equals(42)); |
| 247 }); |
| 248 |
| 249 test("are correctly populated in found", () { |
| 250 expect(new Response.found("okay!", headers: {}, context: { |
| 251 'my-param' : 42 |
| 252 }).context['my-param'], equals(42)); |
| 253 }); |
| 254 |
| 255 test("are correctly populated in internalServerError", () { |
| 256 expect(new Response.internalServerError(headers: {}, context: { |
| 257 'my-param' : 42 |
| 258 }).context['my-param'], equals(42)); |
| 259 }); |
| 260 |
| 261 test("are correctly populated in movedPermanently", () { |
| 262 expect(new Response.movedPermanently("okay!", headers: {}, context: { |
| 263 'my-param' : 42 |
| 264 }).context['my-param'], equals(42)); |
| 265 }); |
| 266 |
| 267 test("are correctly populated in notFound", () { |
| 268 expect(new Response.notFound("okay!", headers: {}, context: { |
| 269 'my-param' : 42 |
| 270 }).context['my-param'], equals(42)); |
| 271 }); |
| 272 |
| 273 test("are correctly populated in notModified", () { |
| 274 expect(new Response.notModified(headers: {}, context: { |
| 275 'my-param' : 42 |
| 276 }).context['my-param'], equals(42)); |
| 277 }); |
| 278 |
| 279 test("are correctly populated in seeOther", () { |
| 280 expect(new Response.seeOther("other", headers: {}, context: { |
| 281 'my-param' : 42 |
| 282 }).context['my-param'], equals(42)); |
| 283 }); |
| 284 }); |
| 285 |
234 } | 286 } |
OLD | NEW |