Skip to content

Commit

Permalink
Use callback instead of cb
Browse files Browse the repository at this point in the history
  • Loading branch information
Alec Robins committed Oct 11, 2016
1 parent 7ed37aa commit 2183d65
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* [render()](/docs/api/ShallowWrapper/render.md)
* [setContext(context)](/docs/api/ShallowWrapper/setContext.md)
* [setProps(nextProps)](/docs/api/ShallowWrapper/setProps.md)
* [setState(nextState[, cb])](/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)
* [some(selector)](/docs/api/ShallowWrapper/some.md)
Expand Down Expand Up @@ -110,8 +110,8 @@
* [ref(refName)](/docs/api/ReactWrapper/ref.md)
* [render()](/docs/api/ReactWrapper/render.md)
* [setContext(context)](/docs/api/ReactWrapper/setContext.md)
* [setProps(nextProps[, cb])](/docs/api/ReactWrapper/setProps.md)
* [setState(nextState[, cb])](/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)
* [some(selector)](/docs/api/ReactWrapper/some.md)
* [someWhere(predicate)](/docs/api/ReactWrapper/someWhere.md)
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[, cb]) => 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. `cb` (`Function` [optional]): If provided, the callback function will be executed once setProps has completed
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[, cb]) => 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. `cb` (`Function` [optional]): If provided, the callback function will be executed once setState has completed
2. `callback` (`Function` [optional]): If provided, the callback function will be executed once setState has completed


#### Returns
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/setState.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `.setState(state[, cb]) => 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. `cb` (`Function` [optional]): If provided, the callback function will be executed once setState has completed
2. `callback` (`Function` [optional]): If provided, the callback function will be executed once setState has completed


#### Returns
Expand Down
8 changes: 4 additions & 4 deletions src/ReactWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ class ReactWrapper {
* @param {Function} cb - callback function
* @returns {ReactWrapper}
*/
setProps(props, cb = undefined) {
setProps(props, callback = undefined) {
if (this.root !== this) {
throw new Error('ReactWrapper::setProps() can only be called on the root');
}
this.component.setChildProps(props, cb);
this.component.setChildProps(props, callback);
return this;
}

Expand All @@ -229,11 +229,11 @@ class ReactWrapper {
* @param {Function} cb - callback function
* @returns {ReactWrapper}
*/
setState(state, cb = undefined) {
setState(state, callback = undefined) {
if (this.root !== this) {
throw new Error('ReactWrapper::setState() can only be called on the root');
}
this.instance().setState(state, cb);
this.instance().setState(state, callback);
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ReactWrapperComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default function createWrapperComponent(node, options = {}) {
};
},

setChildProps(newProps, cb = undefined) {
setChildProps(newProps, callback = undefined) {
const props = objectAssign({}, this.state.props, newProps);
this.setState({ props }, cb);
this.setState({ props }, callback);
},

setChildContext(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ShallowWrapper {
* @param {Function} cb - callback function
* @returns {ShallowWrapper}
*/
setState(state, cb = undefined) {
setState(state, callback = undefined) {
if (this.root !== this) {
throw new Error('ShallowWrapper::setState() can only be called on the root');
}
Expand All @@ -257,7 +257,7 @@ class ShallowWrapper {
}
this.single('setState', () => {
withSetStateAllowed(() => {
this.instance().setState(state, cb);
this.instance().setState(state, callback);
this.update();
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ describeWithDOM('mount', () => {

});

describe('.setProps(newProps[, cb])', () => {
describe('.setProps(newProps[, callback])', () => {
it('should set props for a component multiple times', () => {
class Foo extends React.Component {
render() {
Expand Down Expand Up @@ -1290,7 +1290,7 @@ describeWithDOM('mount', () => {
});
});

describe('.setState(newState[, cb])', () => {
describe('.setState(newState[, callback])', () => {
it('should set the state of the root node', () => {
class Foo extends React.Component {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ describe('shallow', () => {
});
});

describe('.setState(newState[, cb])', () => {
describe('.setState(newState[, callback])', () => {
it('should set the state of the root node', () => {
class Foo extends React.Component {
constructor(props) {
Expand Down

0 comments on commit 2183d65

Please sign in to comment.