Skip to content

Commit

Permalink
Clarify what objects toContain and toContainEqual can be used on (jes…
Browse files Browse the repository at this point in the history
…tjs#4307)

This is just a documentation change to clarify that `toContain` and `toContainEqual` matchers work on arrays and strings (but not objects) rather than the more ambiguous "list".

This also adds consistency, since all other api method docs refer to "arrays", rather than "lists".
  • Loading branch information
benmccormick authored and cpojer committed Aug 20, 2017
1 parent c4575b3 commit 6da6a97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/en/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,9 @@ You could write `expect(bestDrinkForFlavor('octopus')).toBe(undefined)`, but it'

### `.toContain(item)`

Use `.toContain` when you want to check that an item is in a list. For testing the items in the list, this uses `===`, a strict equality check.
Use `.toContain` when you want to check that an item is in an array. For testing the items in the array, this uses `===`, a strict equality check. `.toContain` can also check whether a string is a substring of another string.

For example, if `getAllFlavors()` returns a list of flavors and you want to be sure that `lime` is in there, you can write:
For example, if `getAllFlavors()` returns an array of flavors and you want to be sure that `lime` is in there, you can write:

```js
test('the flavor list contains lime', () => {
Expand All @@ -630,8 +630,8 @@ test('the flavor list contains lime', () => {

### `.toContainEqual(item)`

Use `.toContainEqual` when you want to check that an item is in a list.
For testing the items in the list, this matcher recursively checks the equality of all fields, rather than checking for object identity.
Use `.toContainEqual` when you want to check that an item with a specific structure and values is contained in an array.
For testing the items in the array, this matcher recursively checks the equality of all fields, rather than checking for object identity.

```js
describe('my beverage', () => {
Expand Down

0 comments on commit 6da6a97

Please sign in to comment.