Skip to content

Commit

Permalink
[Tests] use sinon-sandbox instead of sinon
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 24, 2019
1 parent 7ff8ea2 commit edd3a20
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
7 changes: 4 additions & 3 deletions packages/enzyme-test-suite/package.json
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
@@ -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
@@ -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
10 changes: 5 additions & 5 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
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 @@ -7380,12 +7380,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
10 changes: 5 additions & 5 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
@@ -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 @@ -7728,12 +7728,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
@@ -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
@@ -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 test/mocha.opts
@@ -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 edd3a20

Please sign in to comment.