diff --git a/docs/README.md b/docs/README.md index 462894514..aeac40394 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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) @@ -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) diff --git a/docs/api/ReactWrapper/setProps.md b/docs/api/ReactWrapper/setProps.md index 017f499ad..07f8b182c 100644 --- a/docs/api/ReactWrapper/setProps.md +++ b/docs/api/ReactWrapper/setProps.md @@ -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 @@ -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 diff --git a/docs/api/ReactWrapper/setState.md b/docs/api/ReactWrapper/setState.md index 28e8f57a2..b459acb53 100644 --- a/docs/api/ReactWrapper/setState.md +++ b/docs/api/ReactWrapper/setState.md @@ -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 @@ -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 diff --git a/docs/api/ShallowWrapper/setState.md b/docs/api/ShallowWrapper/setState.md index 9be8f2f42..f01a40b4f 100644 --- a/docs/api/ShallowWrapper/setState.md +++ b/docs/api/ShallowWrapper/setState.md @@ -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 @@ -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 diff --git a/src/ReactWrapper.jsx b/src/ReactWrapper.jsx index 0e0ede0aa..5bfbebaf3 100644 --- a/src/ReactWrapper.jsx +++ b/src/ReactWrapper.jsx @@ -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; } @@ -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; } diff --git a/src/ReactWrapperComponent.jsx b/src/ReactWrapperComponent.jsx index 4ef8c1f4c..9d46e67d8 100644 --- a/src/ReactWrapperComponent.jsx +++ b/src/ReactWrapperComponent.jsx @@ -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) { diff --git a/src/ShallowWrapper.js b/src/ShallowWrapper.js index 5cbb93d60..4076d44bb 100644 --- a/src/ShallowWrapper.js +++ b/src/ShallowWrapper.js @@ -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'); } @@ -257,7 +257,7 @@ class ShallowWrapper { } this.single('setState', () => { withSetStateAllowed(() => { - this.instance().setState(state, cb); + this.instance().setState(state, callback); this.update(); }); }); diff --git a/test/ReactWrapper-spec.jsx b/test/ReactWrapper-spec.jsx index 80cdc1e88..829f89733 100644 --- a/test/ReactWrapper-spec.jsx +++ b/test/ReactWrapper-spec.jsx @@ -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() { @@ -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) { diff --git a/test/ShallowWrapper-spec.jsx b/test/ShallowWrapper-spec.jsx index 6d964af54..c6b1be8ba 100644 --- a/test/ShallowWrapper-spec.jsx +++ b/test/ShallowWrapper-spec.jsx @@ -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) {