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

Side by Side Diff: test/peer_test.dart

Issue 1659313002: Fix the tests. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « pubspec.yaml ('k') | test/server/server_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) 2014, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import 'package:stream_channel/stream_channel.dart'; 8 import 'package:stream_channel/stream_channel.dart';
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 var incomingController = new StreamController(); 167 var incomingController = new StreamController();
168 var outgoingController = new StreamController(); 168 var outgoingController = new StreamController();
169 var jsonPeer = new json_rpc.Peer( 169 var jsonPeer = new json_rpc.Peer(
170 new StreamChannel(incomingController.stream, outgoingController)); 170 new StreamChannel(incomingController.stream, outgoingController));
171 171
172 expect(outgoingController.stream.first.then(JSON.decode), completion({ 172 expect(outgoingController.stream.first.then(JSON.decode), completion({
173 "jsonrpc": "2.0", 173 "jsonrpc": "2.0",
174 "error": { 174 "error": {
175 'code': error_code.PARSE_ERROR, 175 'code': error_code.PARSE_ERROR,
176 "message": startsWith("Invalid JSON: "), 176 "message": startsWith("Invalid JSON: "),
177 "data": {'request': '{invalid'} 177 // TODO(nweiz): Always expect the source when sdk#25655 is fixed.
178 "data": {'request': anyOf([isNull, '{invalid'])}
178 }, 179 },
179 "id": null 180 "id": null
180 })); 181 }));
181 182
182 jsonPeer.listen(); 183 jsonPeer.listen();
183 184
184 incomingController.add("{invalid"); 185 incomingController.add("{invalid");
185 }); 186 });
186 187
187 test("returns a response for incorrectly-structured JSON", () { 188 test("returns a response for incorrectly-structured JSON", () {
188 expect(outgoing.first, completion({ 189 expect(outgoing.first, completion({
189 "jsonrpc": "2.0", 190 "jsonrpc": "2.0",
190 "error": { 191 "error": {
191 'code': error_code.INVALID_REQUEST, 192 'code': error_code.INVALID_REQUEST,
192 "message": 'Request must contain a "jsonrpc" key.', 193 "message": 'Request must contain a "jsonrpc" key.',
193 "data": {'request': {'completely': 'wrong'}} 194 "data": {'request': {'completely': 'wrong'}}
194 }, 195 },
195 "id": null 196 "id": null
196 })); 197 }));
197 198
198 peer.listen(); 199 peer.listen();
199 200
200 incoming.add({ 201 incoming.add({
201 "completely": "wrong" 202 "completely": "wrong"
202 }); 203 });
203 }); 204 });
204 }); 205 });
205 } 206 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/server/server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698