talyssonoc / structure

A simple schema/attributes library built on top of modern JavaScript
https://structure.js.org/
MIT License
301 stars 20 forks source link

Create jest structure #107

Closed talyssonoc closed 5 years ago

talyssonoc commented 5 years ago

The intention of this PR is to create a library of custom matchers for Jest that can be used with Structure.

Four matchers were created: toBeValidStructure, toBeInvalidStructure, toHaveInvalidAttribute and toHaveInvalidAttributes.

The reason to have structure in the names of the first two ones is to not have a too generic name that could clash with other custom matcher libraries.

The first two matchers are used when we don't care about what attribute is valid or invalid, we just want to check if the whole structure is valid.

The last two ones are focused on invalidity, where the first one checks the invalidity of a single attribute (optionally passing the error messages), and the second one checks the invalidity of multiple attributes (also optionally passing the error messages).

More details about each of them can be found in the README.me file.