Skip to content

Commit

Permalink
Merge branch 'master' into events
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Mar 19, 2017
2 parents c20e4bf + 595d15f commit 72e919e
Show file tree
Hide file tree
Showing 44 changed files with 1,568 additions and 174 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,13 @@
Thanks for reporting an issue to us! We're glad you are using and invested in Enzyme.
Before submitting, please read over our commonly reported issues to prevent duplicates!

### All common issues

* [common issues](/docs/common-issues)

### Notoriously common issues

* [Webpack build issues](/docs/common-issues#webpackbuildissues)
* [Cannot find module 'react-dom/lib/ReactTestUtils'](/docs/common-issues)
* [Query Selector fails](/docs/common-issues#queryselectorfails)
* [Testing third party libraries](/docs/common-issues#testingthirdpartylibraries)
28 changes: 28 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,33 @@
# Change Log

## 2.7.1 (January 22, 2017)

### Fixes

- `mount`: Fix bug from ([#677](https://github.com/airbnb/enzyme/pull/677) ([#680](https://github.com/airbnb/enzyme/pull/680)
- `mount`: ignore text nodes in childrenOfInst ([#604](https://github.com/airbnb/enzyme/pull/604)

### Documentation

- Update Docs for .getNode and .getNodes ([#743](https://github.com/airbnb/enzyme/pull/743)
- Add a link for `ShallowWrapper#dive()` ([#759](https://github.com/airbnb/enzyme/pull/759)
- Fix alphabetical order of API lists ([#761](https://github.com/airbnb/enzyme/pull/761)

## 2.7.0 (December 21, 2016)

### New Stuff

- `shallow`/`mount`: Add `.slice()` method ([#661](https://github.com/airbnb/enzyme/pull/661))
- `mount`: implement ReactWrapper#getDOMNode ([#679](https://github.com/airbnb/enzyme/pull/679))
- `shallow`/`mount`: Add `exists`; deprecate isEmpty() ([#722](https://github.com/airbnb/enzyme/pull/722))

### Fixes

- `mount`: extract MountedTraversal.hasClassName from MountedTraversal.instHasClassName, which allows ReactWrapper.hasClass to bypass the !isDOMComponent(inst) call ([#677](https://github.com/airbnb/enzyme/pull/677)
- `withDom`: Display a useful error when `withDom` fails to find "jsdom" ([#686](https://github.com/airbnb/enzyme/pull/686))
- `mount`: ensure that `react-text` comment nodes don’t break `.find` ([#691](https://github.com/airbnb/enzyme/pull/691))
- `mount`: `.parents()` now filters out sibling path trees ([#713](https://github.com/airbnb/enzyme/pull/713))

## 2.6.0 (November 9, 2016)

### New Stuff
Expand Down
7 changes: 7 additions & 0 deletions INTHEWILD.md
Expand Up @@ -14,6 +14,12 @@ Organizations
- [Airware](https://github.com/airware)
- [Flatiron School](https://github.com/flatiron-labs)
- [Outreach.io](https://github.com/getoutreach)
- [crowdSPRING](https://crowdspring.com)
- [nteract](https://nteract.io)
- [Brave](https://brave.com)
- [Simple](https://github.com/simplefinance)
- [Grab](https://github.com/grab)
- [Megalytic](https://megalytic.com/)

Projects
----------
Expand All @@ -23,3 +29,4 @@ Projects
- [Recompose](https://github.com/acdlite/recompose)
- [Reapop](https://github.com/LouisBarranqueiro/reapop)
- [React Dates](https://github.com/airbnb/react-dates)
- [nteract notebook](https://github.com/nteract/nteract)
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -21,9 +21,12 @@ should be able to extrapolate to your framework of choice.

If you are interested in using enzyme with custom assertions and convenience functions for
testing your React components, you can consider using:

* [`chai-enzyme`](https://github.com/producthunt/chai-enzyme) with Mocha/Chai.
* [`jasmine-enzyme`](https://github.com/blainekasten/enzyme-matchers/tree/master/packages/jasmine-enzyme) with Jasmine.
* [`jest-enzyme`](https://github.com/blainekasten/enzyme-matchers/tree/master/packages/jest-enzyme) with Jest.
* [`should-enzyme`](https://github.com/rkotze/should-enzyme) for should.js.
* [`expect-enzyme`](https://github.com/PsychoLlama/expect-enzyme) for expect.


[Using Enzyme with Mocha](/docs/guides/mocha.md)
Expand Down Expand Up @@ -73,6 +76,7 @@ Basic Usage

```javascript
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import sinon from 'sinon';

Expand Down Expand Up @@ -119,9 +123,9 @@ Read the full [API Documentation](/docs/api/shallow.md)
```javascript
import React from 'react';
import sinon from 'sinon';
import { expect } from 'chai';
import { mount } from 'enzyme';

import MyComponent from './MyComponent';
import Foo from './Foo';

describe('<Foo />', () => {
Expand Down Expand Up @@ -157,6 +161,7 @@ Read the full [API Documentation](/docs/api/mount.md)

```javascript
import React from 'react';
import { expect } from 'chai';
import { render } from 'enzyme';

import Foo from './Foo';
Expand Down
2 changes: 1 addition & 1 deletion book.json
Expand Up @@ -8,7 +8,7 @@
},
"plugins": [
"edit-link",
"prism",
"prism@2.0.0",
"-highlight",
"github",
"-search",
Expand Down
11 changes: 7 additions & 4 deletions docs/README.md
Expand Up @@ -22,14 +22,16 @@
* [children()](/docs/api/ShallowWrapper/children.md)
* [closest(selector)](/docs/api/ShallowWrapper/closest.md)
* [contains(nodeOrNodes)](/docs/api/ShallowWrapper/contains.md)
* [containsMatchingElement(node)](/docs/api/ShallowWrapper/containsMatchingElement.md)
* [containsAllMatchingElements(nodes)](/docs/api/ShallowWrapper/containsAllMatchingElements.md)
* [containsAnyMatchingElements(nodes)](/docs/api/ShallowWrapper/containsAnyMatchingElements.md)
* [containsMatchingElement(node)](/docs/api/ShallowWrapper/containsMatchingElement.md)
* [context([key])](/docs/api/ShallowWrapper/context.md)
* [debug()](/docs/api/ShallowWrapper/debug.md)
* [dive()](/docs/api/ShallowWrapper/dive.md)
* [equals(node)](/docs/api/ShallowWrapper/equals.md)
* [every(selector)](/docs/api/ShallowWrapper/every.md)
* [everyWhere(predicate)](/docs/api/ShallowWrapper/everyWhere.md)
* [exists()](/docs/api/ShallowWrapper/exists.md)
* [filter(selector)](/docs/api/ShallowWrapper/filter.md)
* [filterWhere(predicate)](/docs/api/ShallowWrapper/filterWhere.md)
* [find(selector)](/docs/api/ShallowWrapper/find.md)
Expand All @@ -41,11 +43,11 @@
* [html()](/docs/api/ShallowWrapper/html.md)
* [instance()](/docs/api/ShallowWrapper/instance.md)
* [is(selector)](/docs/api/ShallowWrapper/is.md)
* [isEmpty()](/docs/api/ShallowWrapper/isEmpty.md)
* [invoke(event[, ...args])](/docs/api/ShallowWrapper/invoke.md)
* [key()](/docs/api/ShallowWrapper/key.md)
* [last()](/docs/api/ShallowWrapper/last.md)
* [map(fn)](/docs/api/ShallowWrapper/map.md)
* [isEmpty()](/docs/api/ShallowWrapper/isEmpty.md)
* [matchesElement(node)](/docs/api/ShallowWrapper/matchesElement.md)
* [name()](/docs/api/ShallowWrapper/name.md)
* [not(selector)](/docs/api/ShallowWrapper/not.md)
Expand Down Expand Up @@ -73,9 +75,9 @@
* [Full DOM Rendering](/docs/api/mount.md)
* [at(index)](/docs/api/ReactWrapper/at.md)
* [contains(nodeOrNodes)](/docs/api/ReactWrapper/contains.md)
* [containsMatchingElement(node)](/docs/api/ReactWrapper/containsMatchingElement.md)
* [containsAllMatchingElements(nodes)](/docs/api/ReactWrapper/containsAllMatchingElements.md)
* [containsAnyMatchingElements(nodes)](/docs/api/ReactWrapper/containsAnyMatchingElements.md)
* [containsMatchingElement(node)](/docs/api/ReactWrapper/containsMatchingElement.md)
* [childAt()](/docs/api/ReactWrapper/childAt.md)
* [children()](/docs/api/ReactWrapper/children.md)
* [closest(selector)](/docs/api/ReactWrapper/closest.md)
Expand All @@ -84,6 +86,7 @@
* [detach()](/docs/api/ReactWrapper/detach.md)
* [every(selector)](/docs/api/ReactWrapper/every.md)
* [everyWhere(predicate)](/docs/api/ReactWrapper/everyWhere.md)
* [exists()](/docs/api/ReactWrapper/exists.md)
* [filter(selector)](/docs/api/ReactWrapper/filter.md)
* [filterWhere(predicate)](/docs/api/ReactWrapper/filterWhere.md)
* [find(selector)](/docs/api/ReactWrapper/find.md)
Expand All @@ -95,10 +98,10 @@
* [html()](/docs/api/ReactWrapper/html.md)
* [instance()](/docs/api/ReactWrapper/instance.md)
* [is(selector)](/docs/api/ReactWrapper/is.md)
* [isEmpty()](/docs/api/ReactWrapper/isEmpty.md)
* [key()](/docs/api/ReactWrapper/key.md)
* [last()](/docs/api/ReactWrapper/last.md)
* [map(fn)](/docs/api/ReactWrapper/map.md)
* [isEmpty()](/docs/api/ReactWrapper/isEmpty.md)
* [matchesElement(node)](/docs/api/ReactWrapper/matchesElement.md)
* [mount()](/docs/api/ReactWrapper/mount.md)
* [name()](/docs/api/ReactWrapper/name.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/containsAllMatchingElements.md
Expand Up @@ -41,5 +41,5 @@ expect(wrapper.containsAllMatchingElements([

- `.containsAllMatchingElements()` expects an array of ReactElement, not a selector (like many other methods). Make sure that
when you are calling it you are calling it with an array of ReactElement or a JSX expression.
- Keep in mind that this method determines mathcing based on the matching of the node's children as
- Keep in mind that this method determines matching based on the matching of the node's children as
well.
18 changes: 18 additions & 0 deletions docs/api/ReactWrapper/exists.md
@@ -0,0 +1,18 @@
# `.exists() => Boolean`

Returns whether or not the current node exists.


#### Returns

`Boolean`: whether or not the current node exists.



#### Example


```jsx
const wrapper = mount(<div className="some-class" />);
expect(wrapper.find('.other-class').exists()).to.be(false);
```
21 changes: 21 additions & 0 deletions docs/api/ReactWrapper/getDOMNode.md
@@ -0,0 +1,21 @@
# `.getDOMNode() => DOMComponent`

Returns the outer most DOMComponent of the current wrapper.

Notes:
- can only be called on a wrapper of a single node.
- will raise if called on a wrapper of a stateless functional component.


#### Returns

`DOMComponent`: The retrieved DOM component.



#### Examples

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.getDOMNode()).to.have.property("className");
```
34 changes: 34 additions & 0 deletions docs/api/ReactWrapper/getNode.md
@@ -0,0 +1,34 @@
# `.getNode() => ReactElement`

Returns the wrapper's underlying node.


#### Returns

`ReactElement`: The retrieved node.



#### Examples

```jsx
class Test extends React.Component {
render() {
return (
<div>
<span />
<span />
</div>
);
}
}

const wrapper = mount(<Test />);
expect(wrapper.getNode()).to.be.an.instanceof(Test);
```



#### Related Methods

- [`.getNodes() => Array<ReactElement>`](getNodes.md)
34 changes: 34 additions & 0 deletions docs/api/ReactWrapper/getNodes.md
@@ -0,0 +1,34 @@
# `.getNodes() => Array<ReactElement>`

Returns the wrapper's underlying nodes.


#### Returns

`Array<ReactElement>`: The retrieved nodes.



#### Examples

```jsx
class Test extends React.Component {
render() {
return (
<div>
<span />
<span />
</div>
);
}
}

const wrapper = mount(<Test />);
expect(wrapper.find('span').getNodes()).to.have.lengthOf(2);
```



#### Related Methods

- [`.getNode() => ReactElement`](getNode.md)
1 change: 1 addition & 0 deletions docs/api/ReactWrapper/isEmpty.md
@@ -1,4 +1,5 @@
# `.isEmpty() => Boolean`
**Deprecated**: Use [.exists()](exists.md) instead.

Returns whether or not the current node is empty.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/matchesElement.md
@@ -1,7 +1,7 @@
# `.matchesElement(node) => Boolean`

Returns whether or not a given react element matches the current render tree.
It will determine if the the wrapper root node __looks like__ the expected element by checking if all props of the expected element are present on the wrapper root node and equals to each other.
It will determine if the the wrapper root node __looks like__ the expected element by checking if all the props supplied in the expected element are present on the wrapper root node and equal to each other. Props present on the wrapper root node but not supplied in the expected element will be ignored.


#### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/setProps.md
Expand Up @@ -12,7 +12,7 @@ NOTE: can only be called on a wrapper instance that is also the root instance.

#### Arguments

1. `props` (`Object`): An object containing new props to merge in with the current state
1. `props` (`Object`): An object containing new props to merge in with the current props
2. `callback` (`Function` [optional]): If provided, the callback function will be executed once setProps has completed


Expand Down
4 changes: 3 additions & 1 deletion docs/api/ShallowWrapper/containsAllMatchingElements.md
@@ -1,7 +1,9 @@
# `.containsAllMatchingElements(nodes) => Boolean`

Returns whether or not one of the given react elements are all matching one element in the shallow render tree.
It will determine if an element in the wrapper __looks like__ one of the expected element by checking if all props of the expected element are present on the wrappers element and equals to each other.
It will determine if the wrapper contains elements which __look like__ each of the expected elements by checking if all props of each expected element are present on the wrapper's elements and equal to each other. Props present on the wrapper elements but not supplied in the expected elements will be ignored.




#### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/containsAnyMatchingElements.md
@@ -1,7 +1,7 @@
# `.containsAnyMatchingElements(nodes) => Boolean`

Returns whether or not one of the given react elements is matching on element in the shallow render tree.
It will determine if an element in the wrapper __looks like__ one of the expected element by checking if all props of the expected element are present on the wrappers element and equals to each other.
It will determine if an element in the wrapper __looks like__ one of the expected elements by checking if all props of the expected element are present on the wrappers element and equal to each other. Props present on the wrapper root node but not supplied in the expected element will be ignored.


#### Arguments
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/containsMatchingElement.md
@@ -1,7 +1,7 @@
# `.containsMatchingElement(node) => Boolean`

Returns whether or not a given react element matches one element in the render tree.
It will determine if an element in the wrapper matches the expected element by checking if all props of the expected element are present on the wrapper's element and equals to each other.
It will determine if an element in the wrapper matches the expected element by checking if all props supplied in the expected element are present on the wrapper's element and equal to each other. Props present on the wrapper element but not supplied in the expected element will be ignored.


#### Arguments
Expand Down
18 changes: 18 additions & 0 deletions docs/api/ShallowWrapper/exists.md
@@ -0,0 +1,18 @@
# `.exists() => Boolean`

Returns whether or not the current node exists.


#### Returns

`Boolean`: whether or not the current node exists.



#### Example


```jsx
const wrapper = shallow(<div className="some-class" />);
expect(wrapper.find('.other-class').exists()).to.be(false);
```
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/findWhere.md
Expand Up @@ -20,7 +20,7 @@ nodes.

```jsx
const wrapper = shallow(<MyComponent />);
const complexComponents = wrapper.findWhere(n => typeof n.type() !== 'string');
const complexComponents = wrapper.findWhere(n => n.type() !== 'string');
expect(complexComponents).to.have.length(8);
```

Expand Down

0 comments on commit 72e919e

Please sign in to comment.