Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
veigaribo committed Apr 14, 2021
1 parent 31cd414 commit 132db78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ a type class (and are thus _instances_ of that class) as _constructors_ and
to the instances of those JavaScript classes as _instance values_.

What this library then allows you to do is to check if every constructor follows
the rules defined in the class, allowing you to modularize your tests in a neat
way.
the rules defined in their classes, so that you to modularize your tests in a
neat way.

### Classes

Expand Down Expand Up @@ -92,6 +92,7 @@ Instances are JavaScript classes that behave according to some (type) class.
Using the Addable example above, one could almost define an instance as:

```javascript
// you may use this decorator as many times as needed
@instance(addable)
class Number {
constructor(n) {
Expand All @@ -118,17 +119,19 @@ class Number {
// ...

static generateData(n) {
// this is quite a trivial example, we just wrap the n
// this is quite a trivial example, we just wrap the n.
// in case you need more random values, just add them as parameters and they
// will be provided
return new Number(n)
}
}
```

With that done, you need only to call `validate` on the instance constructor and
some tests will run. You should call this at some point in your tests.
With that done, you need only to call `validate` on the constructor and the
validators will run. **You should call this at some point in your tests.**

```javascript
// will throw and Error if it fails
// will throw an Error if it fails
validate(Number)
```

Expand Down
4 changes: 3 additions & 1 deletion test/readme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ test('Readme examples work', () => {
}

static generateData(n) {
// this is quite a trivial example, we just wrap the n
// this is quite a trivial example, we just wrap the n.
// in case you need more random values, just add them as parameters and they
// will be provided
return new Number(n)
}
}
Expand Down

0 comments on commit 132db78

Please sign in to comment.