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

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

Issue 256753004: pkg/shelf: change helper method on Request and Response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nits 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library shelf.test_change;
6
7 import 'package:unittest/unittest.dart';
8
9 import 'package:shelf/src/message.dart';
10
11 /// Shared test method used by [Request] and [Response] tests to validate
12 /// the behavior of `change` with different `headers` and `context` values.
13 void testChange(Message factory({Map<String, String> headers,
nweiz 2014/04/29 19:48:48 Rather than calling this method in request_test an
kevmoo 2014/04/30 14:27:52 I like the idea that these are relatively isolated
nweiz 2014/04/30 20:21:39 It's confusing to read. The flow of control bounce
kevmoo 2014/05/02 16:18:01 Done.
14 Map<String, Object> context})) {
15 test('with empty headers returns indentical instance', () {
16 var request = factory(headers: {'header1': 'header value 1'});
17 var copy = request.change(headers: {});
18
19 expect(copy.headers, same(request.headers));
20 });
21
22 test('with empty context returns identical instance', () {
23 var request = factory(context: {'context1': 'context value 1'});
24 var copy = request.change(context: {});
25
26 expect(copy.context, same(request.context));
27 });
28
29 test('new header values are added', () {
30 var request = factory(headers: {'test':'test value'});
31 var copy = request.change(headers: {'test2': 'test2 value'});
32
33 expect(copy.headers, {'test':'test value', 'test2':'test2 value'});
34 });
35
36 test('existing header values are overwritten', () {
37 var request = factory(headers: {'test':'test value'});
38 var copy = request.change(headers: {'test': 'new test value'});
39
40 expect(copy.headers, {'test':'new test value'});
41 });
42
43 test('new context values are added', () {
44 var request = factory(context: {'test':'test value'});
45 var copy = request.change(context: {'test2': 'test2 value'});
46
47 expect(copy.context, {'test':'test value', 'test2':'test2 value'});
48 });
49
50 test('existing context values are overwritten', () {
51 var request = factory(context: {'test':'test value'});
52 var copy = request.change(context: {'test': 'new test value'});
53
54 expect(copy.context, {'test':'new test value'});
55 });
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698