Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Profiler support for adapter-react-16 #2233

Merged
merged 5 commits into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"react/jsx-no-undef": 0,
"react/no-multi-comp": 0,
"react/jsx-one-expression-per-line": 0,
"react/jsx-fragments": 0,
},
},
],
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ matrix:
- node_js: "6"
env: REACT=0.13
env:
- REACT=16.9
- REACT=16.8
- REACT=16.7
- REACT=16.6
Expand Down
6 changes: 3 additions & 3 deletions docs/api/ReactWrapper/everyWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const wrapper = mount((
<div className="foo hoo" />
</div>
));
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('bar'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('bar'))).to.equal(false);
```


Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/filterWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ provided predicate function, return true.

```jsx
const wrapper = mount(<MyComponent />);
const complexComponents = wrapper.find('.foo').filterWhere(n => typeof n.type() !== 'string');
const complexComponents = wrapper.find('.foo').filterWhere((n) => typeof n.type() !== 'string');
expect(complexComponents).to.have.lengthOf(4);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/findWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nodes.

```jsx
const wrapper = mount(<MyComponent />);
const complexComponents = wrapper.findWhere(n => typeof n.type() !== 'string');
const complexComponents = wrapper.findWhere((n) => typeof n.type() !== 'string');
expect(complexComponents).to.have.lengthOf(8);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/key.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Returns the key value for the node of the current wrapper. It must be a single-n
```jsx
const wrapper = mount((
<ul>
{['foo', 'bar'].map(s => <li key={s}>{s}</li>)}
{['foo', 'bar'].map((s) => <li key={s}>{s}</li>)}
</ul>
)).find('li');
expect(wrapper.at(0).key()).to.equal('foo');
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const wrapper = mount((
</div>
));

const texts = wrapper.find('.foo').map(node => node.text());
const texts = wrapper.find('.foo').map((node) => node.text());
expect(texts).to.eql(['bax', 'bar', 'baz']);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/api/ReactWrapper/someWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const wrapper = mount((
<div className="foo hoo" />
</div>
));
expect(wrapper.find('.foo').someWhere(n => n.hasClass('qoo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere(n => n.hasClass('bar'))).to.equal(false);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('qoo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('bar'))).to.equal(false);
```


Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/tap.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ const result = mount((
<li>zzz</li>
</ul>
)).find('li')
.tap(n => console.log(n.debug()))
.map(n => n.text());
.tap((n) => console.log(n.debug()))
.map((n) => n.text());
```
6 changes: 3 additions & 3 deletions docs/api/ShallowWrapper/everyWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const wrapper = shallow((
<div className="foo hoo" />
</div>
));
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('bar'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere((n) => n.hasClass('bar'))).to.equal(false);
```


Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/filterWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ provided predicate function, return true.

```jsx
const wrapper = shallow(<MyComponent />);
const complexFoo = wrapper.find('.foo').filterWhere(n => typeof n.type() !== 'string');
const complexFoo = wrapper.find('.foo').filterWhere((n) => typeof n.type() !== 'string');
expect(complexFoo).to.have.lengthOf(4);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/findWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nodes.

```jsx
const wrapper = shallow(<MyComponent />);
const complexComponents = wrapper.findWhere(n => n.type() !== 'string');
const complexComponents = wrapper.findWhere((n) => n.type() !== 'string');
expect(complexComponents).to.have.lengthOf(8);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/key.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Returns the key value for the node of the current wrapper. It must be a single-n
```jsx
const wrapper = shallow((
<ul>
{['foo', 'bar'].map(s => <li key={s}>{s}</li>)}
{['foo', 'bar'].map((s) => <li key={s}>{s}</li>)}
</ul>
)).find('li');
expect(wrapper.at(0).key()).to.equal('foo');
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const wrapper = shallow((
</div>
));

const texts = wrapper.find('.foo').map(node => node.text());
const texts = wrapper.find('.foo').map((node) => node.text());
expect(texts).to.eql(['bax', 'bar', 'baz']);
```

Expand Down
6 changes: 3 additions & 3 deletions docs/api/ShallowWrapper/someWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const wrapper = shallow((
<div className="foo hoo" />
</div>
));
expect(wrapper.find('.foo').someWhere(n => n.hasClass('qoo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere(n => n.hasClass('bar'))).to.equal(false);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('qoo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').someWhere((n) => n.hasClass('bar'))).to.equal(false);
```


Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/tap.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ const result = shallow((
<li>zzz</li>
</ul>
)).find('li')
.tap(n => console.log(n.debug()))
.map(n => n.text());
.tap((n) => console.log(n.debug()))
.map((n) => n.text());
```
2 changes: 1 addition & 1 deletion docs/guides/jsdom.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ global.navigator = {

function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === 'undefined')
.filter((prop) => typeof target[prop] === 'undefined')
.reduce((result, prop) => ({
...result,
[prop]: Object.getOwnPropertyDescriptor(src, prop),
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/migration-from-2-to-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ enzyme has a `.children()` method which is intended to return the rendered child
When using `mount(...)`, it can sometimes be unclear exactly what this would mean. Consider for
example the following react components:

<!-- eslint react/prop-types: 0, react/prefer-stateless-function: 0 -->
<!-- eslint react/prop-types: 0, react/prefer-stateless-function: 0, max-classes-per-file: 0 -->
```js
class Box extends React.Component {
render() {
Expand Down Expand Up @@ -438,7 +438,7 @@ method.
To get the wrapper that was returned by enzyme 2:
```js
const wrapper = mount(<Bar />);
const refWrapper = wrapper.findWhere(n => n.instance() === wrapper.ref('abc'));
const refWrapper = wrapper.findWhere((n) => n.instance() === wrapper.ref('abc'));
```

## With `mount`, `.instance()` can be called at any level of the tree
Expand Down Expand Up @@ -501,7 +501,7 @@ have found something that did indeed break, please file an issue with us. Thank
enzyme v3 now returns **all** nodes in the result set and not just html nodes.
Consider this example:

<!-- eslint react/prop-types: 0, react/prefer-stateless-function: 0 -->
<!-- eslint react/prop-types: 0, react/prefer-stateless-function: 0, react/jsx-props-no-spreading: 0 -->

```js
const HelpLink = ({ text, ...rest }) => <a {...rest}>{text}</a>;
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ prop, that can be used a selector similar to `className` in standard React:
```

```jsx
expect(wrapper.findWhere(node => node.prop('testID') === 'todo-item')).toExist();
expect(wrapper.findWhere((node) => node.prop('testID') === 'todo-item')).toExist();
```

## Default example configuration for Jest and JSDOM replacement
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('todo-list', () => {
const newTodoTextInput = wrapper.find('Input').first();
const addTodoButton = wrapper
.find('Button')
.findWhere(w => w.text() === 'Add Todo')
.findWhere((w) => w.text() === 'Add Todo')
.first();

newTodoTextInput.props().onChangeText(newTodoText);
Expand All @@ -199,7 +199,7 @@ describe('todo-list', () => {

// You can either check for a testID prop, similar to className in React:
expect(
wrapper.findWhere(node => node.prop('testID') === 'todo-item'),
wrapper.findWhere((node) => node.prop('testID') === 'todo-item'),
).toExist();

// Or even just find a component itself, if you broke the JSX out into its own component:
Expand Down
18 changes: 9 additions & 9 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const spawn = require('child_process').spawn;
const rimraf = require('rimraf');
const semver = require('semver');

const promisify = fn => new Promise((res, rej) => {
const promisify = (fn) => new Promise((res, rej) => {
const done = (err, val) => (err ? rej(err) : res(val));
fn(done);
});
const getFile = fpath => promisify(cb => fs.readFile(fpath, 'utf8', cb));
const getFile = (fpath) => promisify((cb) => fs.readFile(fpath, 'utf8', cb));
// const getFiles = fpath => promisify(cb => fs.readdir(fpath, cb));
const getJSON = fpath => getFile(fpath).then(json => JSON.parse(json));
const getJSON = (fpath) => getFile(fpath).then((json) => JSON.parse(json));
const writeFile = (fpath, src) => promisify((cb) => {
console.log('writeFile', fpath, src);
if (process.env.DEBUG) {
Expand All @@ -25,7 +25,7 @@ const writeJSON = (fpath, json, pretty = false) => writeFile(
fpath,
(pretty ? JSON.stringify(json, null, 2) : JSON.stringify(json)) + '\n'
);
const primraf = fpath => promisify((cb) => {
const primraf = (fpath) => promisify((cb) => {
console.log('rimraf', fpath);
if (process.env.DEBUG) {
cb();
Expand Down Expand Up @@ -104,7 +104,7 @@ const packagesToRemove = [
'react-addons-test-utils',
'react-test-renderer',
'create-react-class',
].map(s => `./node_modules/${s}`);
].map((s) => `./node_modules/${s}`);

const additionalDirsToRemove = [
'node_modules/.bin/npm',
Expand All @@ -116,7 +116,7 @@ const rmrfs = []
.concat(additionalDirsToRemove);

Promise.resolve()
.then(() => Promise.all(rmrfs.map(s => primraf(s))))
.then(() => Promise.all(rmrfs.map((s) => primraf(s))))
.then(() => run('npm', 'i'))
.then(() => Promise.all([
getJSON(adapterPackageJsonPath),
Expand All @@ -125,8 +125,8 @@ Promise.resolve()
.then(([adapterJson, testJson]) => {
const peerDeps = adapterJson.peerDependencies;
const installs = Object.keys(peerDeps)
.filter(key => !key.startsWith('enzyme'))
.map(key => `${key}@${key.startsWith('react') ? reactVersion : peerDeps[key]}`);
.filter((key) => !key.startsWith('enzyme'))
.map((key) => `${key}@${key.startsWith('react') ? reactVersion : peerDeps[key]}`);

if (process.env.RENDERER) {
// eslint-disable-next-line no-param-reassign
Expand All @@ -153,4 +153,4 @@ Promise.resolve()
delete testJson.dependencies[adapterName];
return writeJSON(testPackageJsonPath, testJson, true);
})
.catch(err => console.error(err));
.catch((err) => console.error(err));
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"babel-register": "^6.26.0",
"chai": "^4.2.0",
"coveralls": "^2.13.3",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint": "^6.3.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-markdown": "^1.0.0",
Expand All @@ -86,7 +86,7 @@
"json-loader": "^0.5.7",
"karma": "^1.3.0",
"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.1.0",
"karma-firefox-launcher": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.1",
Expand All @@ -95,8 +95,8 @@
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^10.3.2",
"prop-types": "^15.7.2",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2",
"rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.3",
"semver": "^6.3.0",
"webpack": "^1.15.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-13/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "airbnb",
"root": true,
"rules": {
"max-classes-per-file": 0,
"max-len": 0,
"react/no-find-dom-node": 0,
"react/no-multi-comp": 0,
Expand Down
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.6.0",
"enzyme": "^3.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint": "^6.3.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"in-publish": "^2.0.0",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2"
"rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const getEmptyElementType = (() => {

const createShallowRenderer = function createRendererCompatible() {
const renderer = TestUtils.createRenderer();
renderer.render = (originalRender => function contextCompatibleRender(node, context = {}) {
renderer.render = ((originalRender) => function contextCompatibleRender(node, context = {}) {
ReactContext.current = context;
originalRender.call(this, React.createElement(node.type, node.props), context);
ReactContext.current = {};
Expand Down
8 changes: 4 additions & 4 deletions packages/enzyme-adapter-react-14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.6.0",
"enzyme": "^3.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint": "^6.3.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"in-publish": "^2.0.0",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2"
"rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ReactFourteenAdapter extends EnzymeAdapter {
return {
...this,
...getWrappingComponentMountRenderer({
toTree: inst => instanceToTree(inst._reactInternalInstance),
toTree: (inst) => instanceToTree(inst._reactInternalInstance),
getMountWrapperInstance: () => instance,
}),
};
Expand Down
6 changes: 3 additions & 3 deletions packages/enzyme-adapter-react-15.4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.6.0",
"enzyme": "^3.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint": "^6.3.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"in-publish": "^2.0.0",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2"
"safe-publish-latest": "^1.1.3"
}
}
Loading