Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/testing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
/// import 'dart:convert';
/// import 'package:http/testing.dart';
///
/// var client = new MockClient((request) {
/// var client = new MockClient((request) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be async, but @nex3 would know better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't type check otherwise. The expected type of the constructor argument is

typedef Future<Response> MockClientHandler(Request request);

/// if (request.url.path != "/data.json") {
/// return new Response("", 404);
/// }
/// return new Response(JSON.encode({
/// 'numbers': [1, 4, 15, 19, 214]
/// }, 200, headers: {
/// 'content-type': 'application/json'
/// });
/// };
/// return new Response(
/// JSON.encode({
/// 'numbers': [1, 4, 15, 19, 214]
/// }),
/// 200,
/// headers: {'content-type': 'application/json'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this new formatting reads less well than the original, dartfmt notwithstanding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I actually like the new output. I think the 200 gets a little lost in the before code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ... is this ready to be merged?

(IMHO, the raison d'etre of source code formatters is that they relieve us, as designers, from the tedium and trivialities surrounding code layout :)

/// });
export 'src/mock_client.dart';