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

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: error msg and pubspec tweaks 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
« pkg/shelf/lib/src/request.dart ('K') | « 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..e9711a91b26e5427b0da84a75afa61f8839f8775 100644
--- a/pkg/shelf/test/request_test.dart
+++ b/pkg/shelf/test/request_test.dart
@@ -168,5 +168,49 @@ void main() {
..close();
});
});
+
+ group('with just scriptName', () {
+ 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.
+ var uri = Uri.parse('https://test.example.com/static/file.html');
+
nweiz 2014/05/22 19:50:42 Nit: remove this newline and the next one. Same wi
+ 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'));
+ });
});
}
« pkg/shelf/lib/src/request.dart ('K') | « pkg/shelf/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698