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'; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 expect(copy.context, same(request.context)); | 161 expect(copy.context, same(request.context)); |
162 expect(copy.readAsString(), completion('hello, world')); | 162 expect(copy.readAsString(), completion('hello, world')); |
163 | 163 |
164 controller.add(HELLO_BYTES); | 164 controller.add(HELLO_BYTES); |
165 return new Future(() { | 165 return new Future(() { |
166 controller | 166 controller |
167 ..add(WORLD_BYTES) | 167 ..add(WORLD_BYTES) |
168 ..close(); | 168 ..close(); |
169 }); | 169 }); |
170 }); | 170 }); |
171 | |
172 group('with just scriptName', () { | |
173 test('updates url if striptName matches existing url', () { | |
nweiz
2014/05/22 19:50:42
"striptName" -> "scriptName"
kevmoo
2014/05/22 20:38:36
Done.
| |
174 var uri = Uri.parse('https://test.example.com/static/file.html'); | |
175 | |
nweiz
2014/05/22 19:50:42
Nit: remove this newline and the next one. Same wi
| |
176 var request = new Request('GET', uri); | |
177 | |
178 var copy = request.change(scriptName: '/static'); | |
179 | |
180 expect(copy.scriptName, '/static'); | |
181 expect(copy.url, Uri.parse('/file.html')); | |
182 }); | |
183 | |
184 test('throws if striptName does not match existing url', () { | |
185 var uri = Uri.parse('https://test.example.com/static/file.html'); | |
186 | |
187 var request = new Request('GET', uri); | |
188 | |
189 expect(() => request.change(scriptName: '/nope'), throwsArgumentError); | |
190 }); | |
191 }); | |
192 | |
193 test('url', () { | |
194 var uri = Uri.parse('https://test.example.com/static/file.html'); | |
195 | |
196 var request = new Request('GET', uri); | |
197 | |
198 var copy = request.change(url: Uri.parse('/other_path/file.html')); | |
199 | |
200 expect(copy.scriptName, ''); | |
201 expect(copy.url, Uri.parse('/other_path/file.html')); | |
202 }); | |
203 | |
204 test('scriptName and url', () { | |
205 var uri = Uri.parse('https://test.example.com/static/file.html'); | |
206 | |
207 var request = new Request('GET', uri); | |
208 | |
209 var copy = request.change(scriptName: '/dynamic', | |
210 url: Uri.parse('/other_path/file.html')); | |
211 | |
212 expect(copy.scriptName, '/dynamic'); | |
213 expect(copy.url, Uri.parse('/other_path/file.html')); | |
214 }); | |
171 }); | 215 }); |
172 } | 216 } |
OLD | NEW |