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

Side by Side Diff: pkg/http/lib/testing.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | pkg/http/test/client_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library testing; 5 library testing;
6 6
7 /// This library contains testing classes for the HTTP library. 7 /// This library contains testing classes for the HTTP library.
8 /// 8 ///
9 /// The [MockClient] class is a drop-in replacement for `http.Client` that 9 /// The [MockClient] class is a drop-in replacement for `http.Client` that
10 /// allows test code to set up a local request handler in order to fake a server 10 /// allows test code to set up a local request handler in order to fake a server
11 /// that responds to HTTP requests: 11 /// that responds to HTTP requests:
12 /// 12 ///
13 /// import 'dart:json'; 13 /// import 'dart:json' as json;
14 /// import 'package:http/testing.dart'; 14 /// import 'package:http/testing.dart';
15 /// 15 ///
16 /// var client = new MockClient((request) { 16 /// var client = new MockClient((request) {
17 /// if (request.url.path != "/data.json") { 17 /// if (request.url.path != "/data.json") {
18 /// return new Response("", 404); 18 /// return new Response("", 404);
19 /// } 19 /// }
20 /// return new Response(JSON.stringify({ 20 /// return new Response(json.stringify({
21 /// 'numbers': [1, 4, 15, 19, 214] 21 /// 'numbers': [1, 4, 15, 19, 214]
22 /// }, 200, headers: { 22 /// }, 200, headers: {
23 /// 'content-type': 'application/json' 23 /// 'content-type': 'application/json'
24 /// }); 24 /// });
25 /// }; 25 /// };
26 26
27 export 'src/mock_client.dart'; 27 export 'src/mock_client.dart';
OLDNEW
« no previous file with comments | « pkg/http/lib/src/utils.dart ('k') | pkg/http/test/client_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698