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

Unified Diff: dart/pkg/http_base/test/http_base_test.dart

Issue 445933004: Add implementations for Headers, Request, Response and dart:io/dart:html clients to http_base (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 4 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 | « dart/pkg/http_base/test/http_base_io_test.dart ('k') | dart/pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/http_base/test/http_base_test.dart
diff --git a/dart/pkg/http_base/test/http_base_test.dart b/dart/pkg/http_base/test/http_base_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d6d97e24bc95f3234960fef9c6fa2eef360f751b
--- /dev/null
+++ b/dart/pkg/http_base/test/http_base_test.dart
@@ -0,0 +1,81 @@
+library http_base.http_base_test;
+
+import 'package:http_base/http_base.dart';
+import 'package:unittest/unittest.dart';
+
+main() {
+ group('headers-impl', () {
+ test('empty', () {
+ for (HeadersImpl emptyHeaders in [HeadersImpl.Empty,
+ new HeadersImpl({})]) {
+ expect(emptyHeaders.names, isEmpty);
+ expect(emptyHeaders['foo'], isNull);
+ expect(emptyHeaders.getMultiple('foo'), isNull);
+ }
+ });
+
+ test('multi-value', () {
+ var headers = new HeadersImpl({
+ 'Single' : 'single-value',
+ 'Mul' : ['mul-1', 'mul-2', 'mul-3,mul-4'],
+ 'Mul-Inline' : 'mi-1,mi-2,mi-3',
+ });
+
+ expect(headers.names, hasLength(3));
+ expect(headers.names, contains('single'));
+ expect(headers.names, contains('mul'));
+ expect(headers.names, contains('mul-inline'));
+
+ for (var key in ['Single', 'single']) {
+ expect(headers[key], equals('single-value'));
+ expect(headers.getMultiple(key), equals(['single-value']));
+ }
+
+ for (var key in ['Mul', 'mul']) {
+ expect(headers[key], equals('mul-1,mul-2,mul-3,mul-4'));
+ expect(headers.getMultiple(key),
+ equals(['mul-1','mul-2','mul-3','mul-4']));
+ }
+
+ for (var key in ['Mul-Inline', 'mul-inline']) {
+ expect(headers[key], equals('mi-1,mi-2,mi-3'));
+ expect(headers.getMultiple(key), equals(['mi-1','mi-2','mi-3']));
+ }
+ });
+
+ test('cookie-headers', () {
+ var headers = new HeadersImpl({
+ 'Set-Cookie' : [
+ 'lang=en-US; Expires=Wed, 09 Jun 2021 10:18:14 GMT',
+ 'lang=de-DE; Expires=Wed, 09 Jun 2021 10:18:14 GMT',],
+ 'Cookie' : ['name1=value1; name2=value2', 'name3=value3'],
+ });
+
+ expect(() => headers['set-cookie'], throwsArgumentError);
+ expect(() => headers['cookie'], throwsArgumentError);
+
+ expect(headers.getMultiple('set-cookie').toList(), equals([
+ 'lang=en-US; Expires=Wed, 09 Jun 2021 10:18:14 GMT',
+ 'lang=de-DE; Expires=Wed, 09 Jun 2021 10:18:14 GMT']));
+
+ expect(headers.getMultiple('cookie').toList(),
+ equals(['name1=value1; name2=value2', 'name3=value3']));
+ });
+
+ test('replace', () {
+ var headers = new HeadersImpl({
+ 'Single' : 'single-value',
+ 'Mul' : ['mul-1', 'mul-2', 'mul-3,mul-4'],
+ 'Mul-Inline' : 'mi-1,mi-2,mi-3',
+ }).replace({
+ 'single' : 'foo',
+ 'mul' : null,
+ 'mul-inline' : 'bar',
+ });
+
+ expect(headers.names, hasLength(2));
+ expect(headers['single'], equals('foo'));
+ expect(headers['mul-inline'], equals('bar'));
+ });
+ });
+}
« no previous file with comments | « dart/pkg/http_base/test/http_base_io_test.dart ('k') | dart/pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698