Skip to content

Commit

Permalink
Merge branch 'master' into fix-text-children
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary authored Nov 30, 2016
2 parents f53a63e + 01f415c commit b3524e2
Show file tree
Hide file tree
Showing 42 changed files with 1,654 additions and 573 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ sudo: false
matrix:
fast_finish: true
include:
- node_js: "node"
- node_js: "6"
env: LINT=true
- node_js: "node"
- node_js: "6"
env: EXAMPLE=mocha
- node_js: "node"
- node_js: "6"
env: EXAMPLE=karma
- node_js: "node"
- node_js: "6"
env: EXAMPLE=react-native
- node_js: "node"
- node_js: "6"
env: EXAMPLE=karma-webpack
- node_js: "node"
- node_js: "6"
env: EXAMPLE=jest
- node_js: "node"
- node_js: "6"
env: KARMA=true REACT=0.13
- node_js: "node"
- node_js: "6"
env: KARMA=true REACT=0.14
- node_js: "node"
- node_js: "6"
env: KARMA=true REACT=15
allow_failures:
- node_js: "node"
- node_js: "6"
env: EXAMPLE=react-native
env:
- REACT=0.13
Expand Down
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,64 @@
# Change Log

## 2.6.0 (November 9, 2016)

### New Stuff

- ensure ShallowWrapper render output can't get stale ([#490](https://github.com/airbnb/enzyme/pull/490))

### Fixes

- Use shim to detect constructor function name ([#659](https://github.com/airbnb/enzyme/pull/659))
- `mount`/`shallow`: fix ID selectors ([#670](https://github.com/airbnb/enzyme/pull/670))


## 2.5.2 (November 9, 2016)

### Fixes

- Use shim to detect constructor function name ([#659](https://github.com/airbnb/enzyme/pull/659))
- `mount`/`shallow`: fix ID selectors ([#670](https://github.com/airbnb/enzyme/pull/670))


## 2.5.1 (October 17, 2016)

### Patches

- continue to support one-argument `single` ([#632](https://github.com/airbnb/enzyme/pull/632))


## 2.5.0 (October 17, 2016)

### Minor Changes

- pass callback on setState and setProps ([#617](https://github.com/airbnb/enzyme/pull/617))

- Make ReactWrapper and ShallowWrapper iterable ([#594](https://github.com/airbnb/enzyme/pull/594))

- add `.dive()` method to `shallow` ([#618](https://github.com/airbnb/enzyme/pull/618))


### Patches

- Warn if selector contains a pseudo-class ([#591](https://github.com/airbnb/enzyme/pull/591))

- change isCompoundSelector to not match prop selector ([#595](https://github.com/airbnb/enzyme/pull/595))

- fixed hasClassName in case className is not a string and has toString method ([#518](https://github.com/airbnb/enzyme/pull/518))

- Throw if some() is called on a root wrapper ([#523](https://github.com/airbnb/enzyme/pull/523))

- Fix valid + falsy propvalues ([#563](https://github.com/airbnb/enzyme/pull/563))


## 2.4.2 (November 9, 2016)

### Fixes

- Use shim to detect constructor function name ([#659](https://github.com/airbnb/enzyme/pull/659))
- `mount`/`shallow`: fix ID selectors ([#670](https://github.com/airbnb/enzyme/pull/670))


## 2.4.1 (July 8, 2016)

### Patches
Expand Down
1 change: 1 addition & 0 deletions INTHEWILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Organizations
- [GoDaddy](https://github.com/godaddy)
- [Airware](https://github.com/airware)
- [Flatiron School](https://github.com/flatiron-labs)
- [Outreach.io](https://github.com/getoutreach)

Projects
----------
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ compatible with all major test runners and assertion libraries out there. The do
examples for enzyme use [mocha](https://mochajs.org/) and [chai](http://chaijs.com/), but you
should be able to extrapolate to your framework of choice.

If you are interested in using enzyme with custom Chai.js assertions and convenience functions for
testing your React components, you can consider using [chai-enzyme](https://github.com/producthunt/chai-enzyme).

If you are interested in using enzyme with custom Jasmine/Jest assertions and convenience functions for
testing your React components, you can consider using [jasmine-enzyme](https://github.com/blainekasten/jasmine-enzyme).
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.


[Using Enzyme with Mocha](/docs/guides/mocha.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# selector

A Selector in enzyme is similar to a CSS selector, but can be a number of other things as well in
order to easily specify a criteria by which you want to find nodes in a enzyme wrapper. See the
order to easily specify a criteria by which you want to find nodes in an enzyme wrapper. See the
[Selector page](/docs/api/selector.md) for more information.

# wrapper
Expand Down
12 changes: 7 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* [debug()](/docs/api/ShallowWrapper/debug.md)
* [equals(node)](/docs/api/ShallowWrapper/equals.md)
* [every(selector)](/docs/api/ShallowWrapper/every.md)
* [everyWhere(selector)](/docs/api/ShallowWrapper/everyWhere.md)
* [everyWhere(predicate)](/docs/api/ShallowWrapper/everyWhere.md)
* [filter(selector)](/docs/api/ShallowWrapper/filter.md)
* [filterWhere(predicate)](/docs/api/ShallowWrapper/filterWhere.md)
* [find(selector)](/docs/api/ShallowWrapper/find.md)
Expand Down Expand Up @@ -57,9 +57,10 @@
* [render()](/docs/api/ShallowWrapper/render.md)
* [setContext(context)](/docs/api/ShallowWrapper/setContext.md)
* [setProps(nextProps)](/docs/api/ShallowWrapper/setProps.md)
* [setState(nextState)](/docs/api/ShallowWrapper/setState.md)
* [setState(nextState[, callback])](/docs/api/ShallowWrapper/setState.md)
* [shallow([options])](/docs/api/ShallowWrapper/shallow.md)
* [simulate(event[, data])](/docs/api/ShallowWrapper/simulate.md)
* [slice([begin[, end]])](/docs/api/ShallowWrapper/slice.md)
* [some(selector)](/docs/api/ShallowWrapper/some.md)
* [someWhere(predicate)](/docs/api/ShallowWrapper/someWhere.md)
* [state([key])](/docs/api/ShallowWrapper/state.md)
Expand All @@ -81,7 +82,7 @@
* [debug()](/docs/api/ReactWrapper/debug.md)
* [detach()](/docs/api/ReactWrapper/detach.md)
* [every(selector)](/docs/api/ReactWrapper/every.md)
* [everyWhere(selector)](/docs/api/ReactWrapper/everyWhere.md)
* [everyWhere(predicate)](/docs/api/ReactWrapper/everyWhere.md)
* [filter(selector)](/docs/api/ReactWrapper/filter.md)
* [filterWhere(predicate)](/docs/api/ReactWrapper/filterWhere.md)
* [find(selector)](/docs/api/ReactWrapper/find.md)
Expand Down Expand Up @@ -110,9 +111,10 @@
* [ref(refName)](/docs/api/ReactWrapper/ref.md)
* [render()](/docs/api/ReactWrapper/render.md)
* [setContext(context)](/docs/api/ReactWrapper/setContext.md)
* [setProps(nextProps)](/docs/api/ReactWrapper/setProps.md)
* [setState(nextState)](/docs/api/ReactWrapper/setState.md)
* [setProps(nextProps[, callback])](/docs/api/ReactWrapper/setProps.md)
* [setState(nextState[, callback])](/docs/api/ReactWrapper/setState.md)
* [simulate(event[, data])](/docs/api/ReactWrapper/simulate.md)
* [slice([begin[, end]])](/docs/api/ReactWrapper/slice.md)
* [some(selector)](/docs/api/ReactWrapper/some.md)
* [someWhere(predicate)](/docs/api/ReactWrapper/someWhere.md)
* [state([key])](/docs/api/ReactWrapper/state.md)
Expand Down
27 changes: 21 additions & 6 deletions docs/api/ReactWrapper/contains.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `.contains(nodeOrNodes) => Boolean`

Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like
the one passed in.
Returns whether or not all given react elements match elements in the render tree.
It will determine if an element in the wrapper matches the expected element by checking if the expected element has the same props as the wrapper's element and share the same values.


#### Arguments
Expand All @@ -13,17 +13,27 @@ render tree.

#### Returns

`Boolean`: whether or not the current wrapper has a node anywhere in it's render tree that looks
like the one passed in.
`Boolean`: whether or not the current wrapper has nodes anywhere in its render tree that match
the ones passed in.



#### Example


```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.contains(<div className="foo bar" />)).to.equal(true);
const wrapper = mount(
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);

expect(wrapper.contains(<div data-foo="foo" data-bar="bar">Hello</div>)).to.equal(true);

expect(wrapper.contains(<div data-foo="foo">Hello</div>)).to.equal(false);
expect(wrapper.contains(<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>)).to.equal(false);
expect(wrapper.contains(<div data-foo="foo" data-bar="Hello">Hello</div>)).to.equal(false);
expect(wrapper.contains(<div data-foo="foo" data-bar="bar" />)).to.equal(false);
```

```jsx
Expand All @@ -39,6 +49,11 @@ expect(wrapper.contains([
<span>Hello</span>,
<div>Goodbye</div>,
])).to.equal(true);

expect(wrapper.contains([
<span>Hello</span>,
<div>World</div>,
])).to.equal(false);
```


Expand Down
42 changes: 22 additions & 20 deletions docs/api/ReactWrapper/containsMatchingElement.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `.containsMatchingElement(node) => Boolean`

Returns whether or not a given react element is matching one element in the render tree.
It will determine if an element in the wrapper __looks like__ the expected element by checking if all props of the expected element are present on the wrappers element and equals to each other.
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.


#### Arguments
Expand All @@ -13,35 +13,37 @@ render tree.

#### Returns

`Boolean`: whether or not the current wrapper has a node anywhere in its render tree that looks
like the one passed in.
`Boolean`: whether or not the current wrapper has a node anywhere in its render tree that matches
the one passed in.



#### Example


```jsx
const MyComponent = React.createClass({
handleClick() {
...
},
render() {
return (
<div>
<div onClick={this.handleClick} className="foo bar">Hello</div>
</div>
);
}
});

const wrapper = mount(<MyComponent />);
const wrapper = mount(
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);

expect(wrapper.containsMatchingElement(
<div>Hello</div>
<div data-foo="foo" data-bar="bar">Hello</div>
)).to.equal(true);
expect(wrapper.containsMatchingElement(
<div className="foo bar">Hello</div>
<div data-foo="foo">Hello</div>
)).to.equal(true);

expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="Hello">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" />
)).to.equal(false);
```

#### Common Gotchas
Expand Down
21 changes: 21 additions & 0 deletions docs/api/ReactWrapper/getDOMNode.md
Original file line number Diff line number Diff line change
@@ -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");
```
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/hasClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Returns whether or not the current node has a `className` prop including the pas

#### Returns

`Boolean`: whether or not the current node has the class or note.
`Boolean`: whether or not the current node has the class.



Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/setProps.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `.setProps(props) => Self`
# `.setProps(props[, callback]) => Self`

A method that sets the props of the root component, and re-renders. Useful for when you are
wanting to test how the component behaves over time with changing props. Calling this, for
Expand All @@ -13,7 +13,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

2. `callback` (`Function` [optional]): If provided, the callback function will be executed once setProps has completed


#### Returns
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/setState.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `.setState(state) => Self`
# `.setState(state[, callback]) => Self`

A method to invoke `setState()` on the root component instance similar to how you might in the
definition of the component, and re-renders. This method is useful for testing your component
Expand All @@ -12,7 +12,7 @@ NOTE: can only be called on a wrapper instance that is also the root instance.
#### Arguments

1. `state` (`Object`): An object containing new state to merge in with the current state

2. `callback` (`Function` [optional]): If provided, the callback function will be executed once setState has completed


#### Returns
Expand Down
Loading

0 comments on commit b3524e2

Please sign in to comment.