json_matcher 0.1.7

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 47

JSON Matchers for unit tests

Provides:

  • encodesToJson() matcher which checks if the value encodes to expected JSON
  • isJson() matcher which checks if the string is expected JSON
class Foo {
  final String key;
  final String val;

  Foo(String this.key, String this.val);

  toJson() => {key: val}; // This object can be JSON-encoded
}

void main() {
  test('JSON encoding is performed', () {
    final foo = new Foo('hello', 'world');
    final json = {'hello': 'world'};
    expect(foo, encodesToJson(json)); // Ensuring foo encodes to proper JSON
  });
  
  test('Strings can be matched, key order does not matter', () {
    final string = '{"foo": "bar", "hello": "world"}';
    final json = {'hello': 'world', 'foo': 'bar'};
    expect(string, isJson(json));
  });
}

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

[0.1.7] - 2018-04-01

Fixed

  • Stricter analyzer options

0.1.6 - 2018-03-28

Fixed

  • SCREAMING CAPS deprecation warning in dart:convert

0.1.5 - 2018-03-19

Fixed

  • Fixed minor linter issues in dart 2.0

0.1.4 - 2018-03-19

Fixed

  • Fixed minor linter issues

0.1.3 - 2018-03-19

Added

  • String matcher

0.1.2 - 2018-03-11

Added

  • Analysis options

0.1.1 - 2018-03-11

Added

  • Strong mode enabled

0.1.0 - 2018-03-10

Added

  • encodesToJson() matcher

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  json_matcher: "^0.1.7"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:json_matcher/json_matcher.dart';
  
Version Uploaded Documentation Archive
0.1.7 Apr 1, 2018 Go to the documentation of json_matcher 0.1.7 Download json_matcher 0.1.7 archive
0.1.6 Mar 29, 2018 Go to the documentation of json_matcher 0.1.6 Download json_matcher 0.1.6 archive
0.1.5 Mar 19, 2018 Go to the documentation of json_matcher 0.1.5 Download json_matcher 0.1.5 archive
0.1.4 Mar 19, 2018 Go to the documentation of json_matcher 0.1.4 Download json_matcher 0.1.4 archive
0.1.3 Mar 19, 2018 Go to the documentation of json_matcher 0.1.3 Download json_matcher 0.1.3 archive
0.1.2 Mar 12, 2018 Go to the documentation of json_matcher 0.1.2 Download json_matcher 0.1.2 archive
0.1.1 Mar 12, 2018 Go to the documentation of json_matcher 0.1.1 Download json_matcher 0.1.1 archive
0.1.0 Mar 11, 2018 Go to the documentation of json_matcher 0.1.0 Download json_matcher 0.1.0 archive

Analysis

We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
8 / 100
Health:
Code health derived from static analysis. [more]
75 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
99 / 100
Overall score:
Weighted score of the above. [more]
47
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:json_matcher/json_matcher.dart.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 2 hints.

    Strong-mode analysis of lib/src/is_json.dart failed with the following error:

    line: 7 col: 47
    The function expression type '(String) → dynamic' isn't of type '(dynamic) → dynamic'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Run dartfmt to format lib/src/json.dart.

    Similar analysis of the following files failed:

    • lib/src/processing_matcher.dart (hint)
  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use json_matcher.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
convert >=2.0.0 <3.0.0 2.0.1
matcher >=0.12.0 <0.13.0 0.12.2+1
Transitive dependencies
charcode 1.1.1
path 1.5.1
stack_trace 1.9.2
typed_data 1.1.5
Dev dependencies
test >=0.12.0