| 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 | 9 |
| 9 import 'package:shelf/shelf.dart'; | 10 import 'package:shelf/shelf.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 11 | 12 |
| 12 import 'test_util.dart'; | 13 import 'test_util.dart'; |
| 13 | 14 |
| 14 Request _request([Map<String, String> headers, Stream<List<int>> body]) { | 15 Request _request({Map<String, String> headers, body, Encoding encoding}) { |
| 15 return new Request("GET", LOCALHOST_URI, headers: headers, body: body); | 16 return new Request("GET", LOCALHOST_URI, |
| 17 headers: headers, body: body, encoding: encoding); |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 }); | 120 }); |
| 119 }); | 121 }); |
| 120 | 122 |
| 121 group("ifModifiedSince", () { | 123 group("ifModifiedSince", () { |
| 122 test("is null without an If-Modified-Since header", () { | 124 test("is null without an If-Modified-Since header", () { |
| 123 var request = _request(); | 125 var request = _request(); |
| 124 expect(request.ifModifiedSince, isNull); | 126 expect(request.ifModifiedSince, isNull); |
| 125 }); | 127 }); |
| 126 | 128 |
| 127 test("comes from the Last-Modified header", () { | 129 test("comes from the Last-Modified header", () { |
| 128 var request = | 130 var request = _request( |
| 129 _request({'if-modified-since': 'Sun, 06 Nov 1994 08:49:37 GMT'}); | 131 headers: {'if-modified-since': 'Sun, 06 Nov 1994 08:49:37 GMT'}); |
| 130 expect(request.ifModifiedSince, | 132 expect(request.ifModifiedSince, |
| 131 equals(DateTime.parse("1994-11-06 08:49:37z"))); | 133 equals(DateTime.parse("1994-11-06 08:49:37z"))); |
| 132 }); | 134 }); |
| 133 }); | 135 }); |
| 134 | 136 |
| 135 group('change', () { | 137 group('change', () { |
| 136 test('with no arguments returns instance with equal values', () { | 138 test('with no arguments returns instance with equal values', () { |
| 137 var controller = new StreamController(); | 139 var controller = new StreamController(); |
| 138 | 140 |
| 139 var uri = Uri.parse('https://test.example.com/static/file.html'); | 141 var uri = Uri.parse('https://test.example.com/static/file.html'); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 var uri = Uri.parse('https://test.example.com/static/file.html'); | 198 var uri = Uri.parse('https://test.example.com/static/file.html'); |
| 197 var request = new Request('GET', uri); | 199 var request = new Request('GET', uri); |
| 198 var copy = request.change( | 200 var copy = request.change( |
| 199 scriptName: '/dynamic', url: Uri.parse('/other_path/file.html')); | 201 scriptName: '/dynamic', url: Uri.parse('/other_path/file.html')); |
| 200 | 202 |
| 201 expect(copy.scriptName, '/dynamic'); | 203 expect(copy.scriptName, '/dynamic'); |
| 202 expect(copy.url, Uri.parse('/other_path/file.html')); | 204 expect(copy.url, Uri.parse('/other_path/file.html')); |
| 203 }); | 205 }); |
| 204 }); | 206 }); |
| 205 } | 207 } |
| OLD | NEW |