Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
docs: add usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dferber90 committed Mar 20, 2017
1 parent 109f659 commit 1091414
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,42 @@ Enzyme specific jest matchers
// more expect.extend calls for your own matcheres
// expect.extend({ /* ... */ })
```

## Usage

#### `toRender(selector)`

Passes when at least one element matching the [`selector`](https://github.com/airbnb/enzyme/blob/master/docs/api/selector.md) is found in the wrapper.

```js
import Icon from 'somewhere'

describe('Component', () => {
const wrapper = shallow(<Component />)
it('should render an Icon', () => {
expect(wrapper).toRender(Icon)
})
it('should render a Button', () => {
expect(wrapper).toRender('Button')
})
})
```

#### `toRenderElementTimes(selector, times)`


Passes when the number of elements matching the [`selector`](https://github.com/airbnb/enzyme/blob/master/docs/api/selector.md) found in the wrapper matches `times` exactly.

```js
import Icon from 'somewhere'

describe('Component', () => {
const wrapper = shallow(<Component />)
it('should render one Icon', () => {
expect(wrapper).toRenderElementTimes(Icon, 1)
})
it('should render two Buttons', () => {
expect(wrapper).toRenderElementTimes('Button', 2)
})
})
```

0 comments on commit 1091414

Please sign in to comment.