Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pgangwani authored Mar 26, 2019
2 parents 89b1754 + df7ad40 commit d0c04d9
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Foo() {

```jsx
const wrapper = mount(<Foo />);
const total = wrapper.find(Bar).reduce((amount, n) => amount + n.prop('amount'));
expect(total).to.equal(16);
const total = wrapper.find(Bar).reduce((amount, n) => amount + n.prop('amount'), 0);
expect(total).to.equal(14);
```


Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/reduceRight.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Foo() {

```jsx
const wrapper = mount(<Foo />);
const total = wrapper.find(Bar).reduceRight((amount, n) => amount + n.prop('amount'));
expect(total).to.equal(16);
const total = wrapper.find(Bar).reduceRight((amount, n) => amount + n.prop('amount'), 0);
expect(total).to.equal(14);
```


Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Foo() {

```jsx
const wrapper = shallow(<Foo />);
const total = wrapper.find(Bar).reduce((amount, n) => amount + n.prop('amount'));
expect(total).to.equal(16);
const total = wrapper.find(Bar).reduce((amount, n) => amount + n.prop('amount'), 0);
expect(total).to.equal(14);
```


Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/reduceRight.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Foo() {

```jsx
const wrapper = shallow(<Foo />);
const total = wrapper.find(Bar).reduceRight((amount, n) => amount + n.prop('amount'));
expect(total).to.equal(16);
const total = wrapper.find(Bar).reduceRight((amount, n) => amount + n.prop('amount'), 0);
expect(total).to.equal(14);
```


Expand Down
7 changes: 4 additions & 3 deletions packages/enzyme-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"license": "MIT",
"dependencies": {
"chai": "^4.1.2",
"create-react-class": "^15.6.3",
"enzyme": "^3.8.0",
"enzyme-adapter-utils": "^1.9.1",
"html-element-map": "^1.0.0",
Expand All @@ -40,21 +41,21 @@
"object-inspect": "^1.6.0",
"object.assign": "^4.1.0",
"prop-types": "^15.7.2",
"react-is": "^16.8.4",
"semver": "^5.6.0",
"sinon-sandbox": "^2.0.0",
"sinon": "^5.1.1"
},
"peerDependencies": {
"react": "^15.5.0",
"react-dom": "^15.5.0"
},
"devDependencies": {
"create-react-class": "^15.6.3",
"eslint": "^5.15.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-mocha": "^5.2.1",
"eslint-plugin-react": "^7.12.4",
"react-is": "^16.8.4"
"eslint-plugin-react": "^7.12.4"
}
}
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/Debug-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import React from 'react';
import wrap from 'mocha-wrap';
import sinon from 'sinon';
import sinon from 'sinon-sandbox';

import { mount, shallow } from 'enzyme';
import { get } from 'enzyme/build/configuration';
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/RSTTraversal-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import sinon from 'sinon';
import sinon from 'sinon-sandbox';
import { expect } from 'chai';
import { elementToTree } from 'enzyme-adapter-utils';
import {
Expand Down
16 changes: 8 additions & 8 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
import sinon from 'sinon';
import sinon from 'sinon-sandbox';
import wrap from 'mocha-wrap';
import isEqual from 'lodash.isequal';
import getData from 'html-element-map/getData';
Expand Down Expand Up @@ -3141,7 +3141,7 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SimpleComponent />);
expect(() => wrapper.setContext({ name: 'bar' })).to.throw(
Error,
'ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
'ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
);
});

Expand Down Expand Up @@ -3170,7 +3170,7 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SimpleComponent />);
expect(() => wrapper.setContext({ name: 'bar' })).to.throw(
Error,
'ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
'ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option', // eslint-disable-line max-len
);
});
});
Expand Down Expand Up @@ -7891,12 +7891,12 @@ describeWithDOM('mount', () => {
}
}

const cDU = sinon.spy(DummyComp.prototype, 'componentDidUpdate');
const gDSFP = sinon.spy(DummyComp, 'getDerivedStateFromProps');
let cDU;
let gDSFP;

beforeEach(() => { // eslint-disable-line mocha/no-sibling-hooks
cDU.resetHistory();
gDSFP.resetHistory();
cDU = sinon.spy(DummyComp.prototype, 'componentDidUpdate');
gDSFP = sinon.spy(DummyComp, 'getDerivedStateFromProps');
});

it('with no state changes, calls both methods with a sync and async setProps', () => {
Expand Down Expand Up @@ -9370,7 +9370,7 @@ describeWithDOM('mount', () => {

onChange() {
// enzyme can't handle the update because `this` is a ReactComponent instance,
// not a ShallowWrapper instance.
// not a Wrapper instance.
this.setState({ foo: 'onChange update' });
}

Expand Down
10 changes: 5 additions & 5 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
import sinon from 'sinon';
import sinon from 'sinon-sandbox';
import wrap from 'mocha-wrap';
import isEqual from 'lodash.isequal';
import getData from 'html-element-map/getData';
Expand Down Expand Up @@ -8164,12 +8164,12 @@ describe('shallow', () => {
}
}

const cDU = sinon.spy(DummyComp.prototype, 'componentDidUpdate');
const gDSFP = sinon.spy(DummyComp, 'getDerivedStateFromProps');
let cDU;
let gDSFP;

beforeEach(() => { // eslint-disable-line mocha/no-sibling-hooks
cDU.resetHistory();
gDSFP.resetHistory();
cDU = sinon.spy(DummyComp.prototype, 'componentDidUpdate');
gDSFP = sinon.spy(DummyComp, 'getDerivedStateFromProps');
});

it('with no state changes, calls both methods with a sync and async setProps', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/Utils-spec.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { expect } from 'chai';
import wrap from 'mocha-wrap';
import sinon from 'sinon';
import sinon from 'sinon-sandbox';
import {
childrenToSimplifiedArray,
nodeEqual,
Expand Down
5 changes: 5 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/beforeEach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import sinon from 'sinon-sandbox';

beforeEach(() => { // eslint-disable-line mocha/no-top-level-hooks
sinon.restore();
});
2 changes: 1 addition & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class ReactWrapper {
throw new Error('ReactWrapper::setContext() can only be called on the root');
}
if (!this[OPTIONS].context) {
throw new Error('ShallowWrapper::setContext() can only be called on a wrapper that was originally passed a context option');
throw new Error('ReactWrapper::setContext() can only be called on a wrapper that was originally passed a context option');
}
this[RENDERER].render(this[UNRENDERED], context, () => this.update());
return this;
Expand Down
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--require ./packages/enzyme/withDom.js ./packages/enzyme-test-suite/test/_helpers/setupAdapters.js
--require ./packages/enzyme/withDom.js ./packages/enzyme-test-suite/test/_helpers/setupAdapters.js ./packages/enzyme-test-suite/test/_helpers/beforeEach.js
--compilers js:babel-core/register,jsx:babel-core/register
--extensions js,jsx

0 comments on commit d0c04d9

Please sign in to comment.