json_matcher 0.1.2 json_matcher: ^0.1.2 copied to clipboard
JSON Matcher for unit tests. Adds encodesTo() matcher which checks if the value encodes to a certain JSON
JSON Matcher for unit tests #
Provides encodesToJson()
matcher which checks if the value encodes to 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
});
}