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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 test("is null without a Last-Modified header", () { | 150 test("is null without a Last-Modified header", () { |
151 expect(new Response.ok("okay!").lastModified, isNull); | 151 expect(new Response.ok("okay!").lastModified, isNull); |
152 }); | 152 }); |
153 | 153 |
154 test("comes from the Last-Modified header", () { | 154 test("comes from the Last-Modified header", () { |
155 expect(new Response.ok("okay!", headers: { | 155 expect(new Response.ok("okay!", headers: { |
156 'last-modified': 'Sun, 06 Nov 1994 08:49:37 GMT' | 156 'last-modified': 'Sun, 06 Nov 1994 08:49:37 GMT' |
157 }).lastModified, equals(DateTime.parse("1994-11-06 08:49:37z"))); | 157 }).lastModified, equals(DateTime.parse("1994-11-06 08:49:37z"))); |
158 }); | 158 }); |
159 }); | 159 }); |
| 160 |
| 161 group("context", () { |
| 162 test("are correctly populated in ok", () { |
| 163 expect(new Response.ok("okay!", headers: {}, context: { |
| 164 'my-param' : 42 |
| 165 }).context['my-param'], equals(42)); |
| 166 }); |
| 167 |
| 168 test("is correctly populated in forbidden", () { |
| 169 expect(new Response.forbidden("okay!", headers: {}, context: { |
| 170 'my-param' : 42 |
| 171 }).context['my-param'], equals(42)); |
| 172 }); |
| 173 |
| 174 test("is correctly populated in found", () { |
| 175 expect(new Response.found("okay!", headers: {}, context: { |
| 176 'my-param' : 42 |
| 177 }).context['my-param'], equals(42)); |
| 178 }); |
| 179 |
| 180 test("is correctly populated in internalServerError", () { |
| 181 expect(new Response.internalServerError(headers: {}, context: { |
| 182 'my-param' : 42 |
| 183 }).context['my-param'], equals(42)); |
| 184 }); |
| 185 |
| 186 test("is correctly populated in movedPermanently", () { |
| 187 expect(new Response.movedPermanently("okay!", headers: {}, context: { |
| 188 'my-param' : 42 |
| 189 }).context['my-param'], equals(42)); |
| 190 }); |
| 191 |
| 192 test("is correctly populated in notFound", () { |
| 193 expect(new Response.notFound("okay!", headers: {}, context: { |
| 194 'my-param' : 42 |
| 195 }).context['my-param'], equals(42)); |
| 196 }); |
| 197 |
| 198 test("is correctly populated in notModified", () { |
| 199 expect(new Response.notModified(headers: {}, context: { |
| 200 'my-param' : 42 |
| 201 }).context['my-param'], equals(42)); |
| 202 }); |
| 203 |
| 204 test("is correctly populated in seeOther", () { |
| 205 expect(new Response.seeOther("other", headers: {}, context: { |
| 206 'my-param' : 42 |
| 207 }).context['my-param'], equals(42)); |
| 208 }); |
| 209 }); |
160 } | 210 } |
OLD | NEW |