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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/test/request_test.dart
diff --git a/pkg/shelf/test/request_test.dart b/pkg/shelf/test/request_test.dart
index c48a4f73a767810f92fa5924cb46080d990d7a10..fed460f2f6bd3921d9a02b4ff21492e5fbb8724d 100644
--- a/pkg/shelf/test/request_test.dart
+++ b/pkg/shelf/test/request_test.dart
@@ -168,5 +168,42 @@ void main() {
..close();
});
});
+
+ group('with just scriptName', () {
+ test('updates url if scriptName matches existing url', () {
+ var uri = Uri.parse('https://test.example.com/static/file.html');
+ var request = new Request('GET', uri);
+ var copy = request.change(scriptName: '/static');
+
+ expect(copy.scriptName, '/static');
+ expect(copy.url, Uri.parse('/file.html'));
+ });
+
+ test('throws if striptName does not match existing url', () {
+ var uri = Uri.parse('https://test.example.com/static/file.html');
+ var request = new Request('GET', uri);
+
+ expect(() => request.change(scriptName: '/nope'), throwsArgumentError);
+ });
+ });
+
+ test('url', () {
+ var uri = Uri.parse('https://test.example.com/static/file.html');
+ var request = new Request('GET', uri);
+ var copy = request.change(url: Uri.parse('/other_path/file.html'));
+
+ expect(copy.scriptName, '');
+ expect(copy.url, Uri.parse('/other_path/file.html'));
+ });
+
+ test('scriptName and url', () {
+ var uri = Uri.parse('https://test.example.com/static/file.html');
+ var request = new Request('GET', uri);
+ var copy = request.change(scriptName: '/dynamic',
+ url: Uri.parse('/other_path/file.html'));
+
+ expect(copy.scriptName, '/dynamic');
+ expect(copy.url, Uri.parse('/other_path/file.html'));
+ });
});
}
« 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