Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: pkg/shelf/test/request_test.dart

Issue 294123011: pkg/shelf: added `url` and `scriptName` named params to Request.change (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: doc comment tweak Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 scriptName matches existing url', () {
174 var uri = Uri.parse('https://test.example.com/static/file.html');
175 var request = new Request('GET', uri);
176 var copy = request.change(scriptName: '/static');
177
178 expect(copy.scriptName, '/static');
179 expect(copy.url, Uri.parse('/file.html'));
180 });
181
182 test('throws if striptName does not match existing url', () {
183 var uri = Uri.parse('https://test.example.com/static/file.html');
184 var request = new Request('GET', uri);
185
186 expect(() => request.change(scriptName: '/nope'), throwsArgumentError);
187 });
188 });
189
190 test('url', () {
191 var uri = Uri.parse('https://test.example.com/static/file.html');
192 var request = new Request('GET', uri);
193 var copy = request.change(url: Uri.parse('/other_path/file.html'));
194
195 expect(copy.scriptName, '');
196 expect(copy.url, Uri.parse('/other_path/file.html'));
197 });
198
199 test('scriptName and url', () {
200 var uri = Uri.parse('https://test.example.com/static/file.html');
201 var request = new Request('GET', uri);
202 var copy = request.change(scriptName: '/dynamic',
203 url: Uri.parse('/other_path/file.html'));
204
205 expect(copy.scriptName, '/dynamic');
206 expect(copy.url, Uri.parse('/other_path/file.html'));
207 });
171 }); 208 });
172 } 209 }
OLDNEW
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698