OLD | NEW |
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:convert'; | 5 import 'dart:convert'; |
6 | 6 |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 import 'package:json_rpc_2/error_code.dart' as error_code; | 8 import 'package:json_rpc_2/error_code.dart' as error_code; |
9 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; | 9 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 data: 'data value'); | 106 data: 'data value'); |
107 }); | 107 }); |
108 | 108 |
109 test("a JSON parse error is rejected", () { | 109 test("a JSON parse error is rejected", () { |
110 return controller.handleJsonRequest('invalid json {').then((result) { | 110 return controller.handleJsonRequest('invalid json {').then((result) { |
111 expect(JSON.decode(result), { | 111 expect(JSON.decode(result), { |
112 'jsonrpc': '2.0', | 112 'jsonrpc': '2.0', |
113 'error': { | 113 'error': { |
114 'code': error_code.PARSE_ERROR, | 114 'code': error_code.PARSE_ERROR, |
115 'message': startsWith("Invalid JSON: "), | 115 'message': startsWith("Invalid JSON: "), |
116 'data': {'request': 'invalid json {'} | 116 // TODO(nweiz): Always expect the source when sdk#25655 is fixed. |
| 117 'data': {'request': anyOf([isNull, 'invalid json {'])} |
117 }, | 118 }, |
118 'id': null | 119 'id': null |
119 }); | 120 }); |
120 }); | 121 }); |
121 }); | 122 }); |
122 | 123 |
123 group("fallbacks", () { | 124 group("fallbacks", () { |
124 test("calls a fallback if no method matches", () { | 125 test("calls a fallback if no method matches", () { |
125 controller.server | 126 controller.server |
126 ..registerMethod('foo', () => 'foo') | 127 ..registerMethod('foo', () => 'foo') |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 })); | 181 })); |
181 }); | 182 }); |
182 }); | 183 }); |
183 | 184 |
184 test("disallows multiple methods with the same name", () { | 185 test("disallows multiple methods with the same name", () { |
185 controller.server.registerMethod('foo', () => null); | 186 controller.server.registerMethod('foo', () => null); |
186 expect(() => controller.server.registerMethod('foo', () => null), | 187 expect(() => controller.server.registerMethod('foo', () => null), |
187 throwsArgumentError); | 188 throwsArgumentError); |
188 }); | 189 }); |
189 } | 190 } |
OLD | NEW |