Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |