<commit_before>[![npm](https://img.shields.io/npm/v/rebem-test-utils.svg?style=flat-square)](https://www.npmjs.com/package/rebem-test-utils)
[![travis](http://img.shields.io/travis/rebem/rebem-test-utils.svg?style=flat-square)](https://travis-ci.org/rebem/rebem-test-utils)
[![coverage](https://img.shields.io/codecov/c/github/rebem/rebem-test-utils.svg?style=flat-square)](https://codecov.io/github/rebem/rebem-test-utils)
[![deps](https://img.shields.io/gemnasium/rebem/rebem-test-utils.svg?style=flat-square)](https://gemnasium.com/rebem/rebem-test-utils)

reBEM addons for React Test Utilities.

WIP.<commit_msg>:pencil: update README<commit_after>[![npm](https://img.shields.io/npm/v/rebem-test-utils.svg?style=flat-square)](https://www.npmjs.com/package/rebem-test-utils)
[![travis](http://img.shields.io/travis/rebem/test-utils.svg?style=flat-square)](https://travis-ci.org/rebem/test-utils)
[![coverage](https://img.shields.io/codecov/c/github/rebem/test-utils.svg?style=flat-square)](https://codecov.io/github/rebem/test-utils)
[![deps](https://img.shields.io/gemnasium/rebem/test-utils.svg?style=flat-square)](https://gemnasium.com/rebem/test-utils)

[reBEM](https://github.com/rebem/rebem) addons for [React Test Utilities](https://facebook.github.io/react/docs/test-utils.html).

## Install

```
npm i -D rebem-test-utils
```

## Overview

In addition to usual `react-addons-test-utils` helpers there are few new which lets you search for components by [BEM PropTypes](https://github.com/rebem/rebem#bem-proptypes):

* `block`
* `elem`
* `mods`
* `mix`
* `tag`

### `scryRenderedDOMComponentsWithBEM(tree, bem)`

```js
import { BEM } from 'rebem';
import TestUtils from 'rebem-test-utils';

const tree = reBEMTestUtils.renderIntoDocument(
    BEM({ block: 'block' },
        BEM({ block: 'block', elem: 'elem' }),
        BEM({ block: 'block', elem: 'elem' })
    )
);

const elems = TestUtils.scryRenderedDOMComponentsWithBEM(tree, { block: 'block', elem: 'elem' });

console.log(elems.length);
// 2

console.log(
    elems.every(elem => TestUtils.isDOMComponent(elem))
);
// true
```

### `findRenderedDOMComponentWithBEM(tree, bem)`

```js
import { BEM } from 'rebem';
import TestUtils from 'rebem-test-utils';

const tree = reBEMTestUtils.renderIntoDocument(
    BEM({ block: 'block' },
        BEM({ block: 'block', elem: 'elem' })
    )
);

const elem = TestUtils.findRenderedDOMComponentWithBEM(tree, { block: 'block', elem: 'elem' });

console.log(
    TestUtils.isDOMComponent(elem)
);
// true
```
{'fraction_non_alphanumeric': 0.198967434471803, 'fraction_numerical': 0.0003971405877680699, 'mean_word_length': 4.871794871794871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 17, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4750424', 'n_tokens_mistral': 976, 'n_tokens_neox': 954, 'n_words': 124}