Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Asserts the items contained by a Set satisfy a particular list of items. | ||
|
||
```js | ||
expect(new Set([1, 2, 3]), 'to have items satisfying', [1, { foo: 'bar' }, 3]); | ||
``` | ||
|
||
```output | ||
expected Set([ 1, 2, 3 ]) to have items satisfying [ 1, { foo: 'bar' }, 3 ] | ||
Set([ | ||
1, // should equal [ 1, { foo: 'bar' }, 3 ] | ||
2, // should equal [ 1, { foo: 'bar' }, 3 ] | ||
3 // should equal [ 1, { foo: 'bar' }, 3 ] | ||
]) | ||
``` | ||
|
||
In order to check a property holds for all the items, an assertion can be | ||
passed as the argument – in this example we assert that all the items in | ||
the set are numbers: | ||
|
||
```js | ||
expect(new Set([1, 2, []]), 'to have items satisfying', 'to be a number'); | ||
``` | ||
|
||
```output | ||
expected Set([ 1, 2, [] ]) to have items satisfying to be a number | ||
Set([ | ||
1, | ||
2, | ||
[] // should be a number | ||
]) | ||
``` | ||
|
||
The exact number of elements in a Set must always be matched. However, nested | ||
objects are, be default, compared using "satisfy" semantics which allow missing | ||
properties. In order to enforce that all properties are present, the `exhaustively` | ||
flag can be used: | ||
|
||
```js | ||
expect(new Set([[{ foo: true, bar: true }], [1]]), 'to have items satisfying', [ | ||
expect.it('to be an object'), | ||
]); | ||
``` | ||
|
||
```output | ||
expected Set to have items satisfying [ expect.it('to be an object') ] | ||
Set([ | ||
[ { foo: true, bar: true } ], | ||
[ | ||
1 // should be an object | ||
] | ||
]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.