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

Side by Side Diff: pkg/http/test/mock_client_test.dart

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 3 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
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 mock_client_test; 5 library mock_client_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:json' as json; 8 import 'dart:convert';
9 9
10 import 'package:http/http.dart' as http; 10 import 'package:http/http.dart' as http;
11 import 'package:http/src/utils.dart'; 11 import 'package:http/src/utils.dart';
12 import 'package:http/testing.dart'; 12 import 'package:http/testing.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 import 'utils.dart'; 15 import 'utils.dart';
16 16
17 void main() { 17 void main() {
18 test('handles a request', () { 18 test('handles a request', () {
19 var client = new MockClient((request) { 19 var client = new MockClient((request) {
20 return new Future.value(new http.Response( 20 return new Future.value(new http.Response(
21 json.stringify(request.bodyFields), 200, 21 JSON.encode(request.bodyFields), 200,
22 request: request, headers: {'content-type': 'application/json'})); 22 request: request, headers: {'content-type': 'application/json'}));
23 }); 23 });
24 24
25 expect(client.post("http://example.com/foo", fields: { 25 expect(client.post("http://example.com/foo", fields: {
26 'field1': 'value1', 26 'field1': 'value1',
27 'field2': 'value2' 27 'field2': 'value2'
28 }).then((response) => response.body), completion(parse(equals({ 28 }).then((response) => response.body), completion(parse(equals({
29 'field1': 'value1', 29 'field1': 'value1',
30 'field2': 'value2' 30 'field2': 'value2'
31 })))); 31 }))));
(...skipping 23 matching lines...) Expand all
55 55
56 test('handles a request with no body', () { 56 test('handles a request with no body', () {
57 var client = new MockClient((request) { 57 var client = new MockClient((request) {
58 return new Future.value(new http.Response('you did it', 200)); 58 return new Future.value(new http.Response('you did it', 200));
59 }); 59 });
60 60
61 expect(client.read("http://example.com/foo"), 61 expect(client.read("http://example.com/foo"),
62 completion(equals('you did it'))); 62 completion(equals('you did it')));
63 }); 63 });
64 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698