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

7846/use property initializer syntax #8117

Merged
merged 17 commits into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### Chore & Maintenance

- `[*]` Make sure to include `d.ts` files in the tarball when building ([#8086](https://github.com/facebook/jest/pull/8086))
- `[*]` Use property initializer syntax in Jest codebase [#8117](https://github.com/facebook/jest/pull/8117)

### Performance

Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = {
plugins: [
['@babel/plugin-transform-modules-commonjs', {allowTopLevelThis: true}],
'@babel/plugin-transform-strict-mode',
'@babel/plugin-proposal-class-properties',
],
presets: [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ PASS __tests__/console.test.js
15 | });
16 |

at BufferedConsole.log (../../packages/jest-console/build/BufferedConsole.js:180:10)
at BufferedConsole.log (../../packages/jest-console/build/BufferedConsole.js:199:10)
at log (__tests__/console.test.js:13:13)
`;
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ FAIL __tests__/index.js
12 | module.exports = () => 'test';
13 |

at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:435:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:455:17)
at Object.require (index.js:10:1)
`;
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ FAIL __tests__/test.js
| ^
4 |

at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:202:17)
at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:222:17)
at Object.require (index.js:3:18)
`;
1 change: 1 addition & 0 deletions examples/enzyme/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties']
};
15 changes: 5 additions & 10 deletions examples/enzyme/CheckboxWithLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
import React from 'react';

export default class CheckboxWithLabel extends React.Component {
constructor(props) {
super(props);
this.state = {isChecked: false};
state = {
isChecked: false,
};

// bind manually because React class components don't auto-bind
// http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding
this.onChange = this.onChange.bind(this);
}

onChange() {
onChange = () => {
this.setState({isChecked: !this.state.isChecked});
}
};

render() {
return (
Expand Down
1 change: 1 addition & 0 deletions examples/enzyme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"devDependencies": {
"@babel/core": "*",
"@babel/plugin-proposal-class-properties": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
1 change: 1 addition & 0 deletions examples/react-testing-library/.babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties']
};
13 changes: 3 additions & 10 deletions examples/react-testing-library/CheckboxWithLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import React from 'react';

export default class CheckboxWithLabel extends React.Component {
constructor(props) {
super(props);
this.state = {isChecked: false};
state = {isChecked: false};

// bind manually because React class components don't auto-bind
// http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding
this.onChange = this.onChange.bind(this);
}

onChange() {
onChange = () => {
this.setState({isChecked: !this.state.isChecked});
}
};

render() {
return (
Expand Down
1 change: 1 addition & 0 deletions examples/react-testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"devDependencies": {
"@babel/core": "*",
"@babel/plugin-proposal-class-properties": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
8 changes: 2 additions & 6 deletions examples/react/CheckboxWithLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ export default class CheckboxWithLabel extends React.Component {
constructor(props) {
super(props);
this.state = {isChecked: false};

// bind manually because React class components don't auto-bind
// http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding
this.onChange = this.onChange.bind(this);
}

onChange() {
onChange = () => {
this.setState({isChecked: !this.state.isChecked});
}
};

render() {
return (
Expand Down
11 changes: 4 additions & 7 deletions examples/snapshot/Link.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ export default class Link extends React.Component {
constructor() {
super();

this._onMouseEnter = this._onMouseEnter.bind(this);
this._onMouseLeave = this._onMouseLeave.bind(this);

this.state = {
class: STATUS.NORMAL,
};
}

_onMouseEnter() {
_onMouseEnter = () => {
this.setState({class: STATUS.HOVERED});
}
};

_onMouseLeave() {
_onMouseLeave = () => {
this.setState({class: STATUS.NORMAL});
}
};

render() {
return (
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"private": true,
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.1.0",
Expand Down
6 changes: 1 addition & 5 deletions packages/jest-core/src/TestSequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ type Cache = {
* is called to store/update this information on the cache map.
*/
export default class TestSequencer {
private _cache: Map<Context, Cache>;

constructor() {
this._cache = new Map();
}
private _cache: Map<Context, Cache> = new Map();

_getCachePath(context: Context) {
const {config} = context;
Expand Down
15 changes: 5 additions & 10 deletions packages/jest-core/src/plugins/update_snapshots_interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ import {BaseWatchPlugin, JestHookSubscriber} from 'jest-watcher';
import SnapshotInteractiveMode from '../SnapshotInteractiveMode';

class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin {
private _snapshotInteractiveMode: SnapshotInteractiveMode;
private _failedSnapshotTestAssertions: Array<AssertionLocation>;
isInternal: true;

constructor(options: {stdin: NodeJS.ReadStream; stdout: NodeJS.WriteStream}) {
super(options);
this._failedSnapshotTestAssertions = [];
this._snapshotInteractiveMode = new SnapshotInteractiveMode(this._stdout);
this.isInternal = true;
}
private _snapshotInteractiveMode: SnapshotInteractiveMode = new SnapshotInteractiveMode(
this._stdout,
);
private _failedSnapshotTestAssertions: Array<AssertionLocation> = [];
isInternal: true = true;

getFailedSnapshotTestAssertions(
testResults: AggregatedResult,
Expand Down
6 changes: 2 additions & 4 deletions packages/jest-watcher/src/lib/Prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ export default class Prompt {
this._onChange = () => {};
this._onSuccess = () => {};
this._onCancel = () => {};

this._onResize = this._onResize.bind(this);
}

private _onResize() {
private _onResize = () => {
this._onChange();
}
};

enter(
onChange: (pattern: string, options: ScrollOptions) => void,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
"@babel/helper-remap-async-to-generator" "^7.1.0"
"@babel/plugin-syntax-async-generators" "^7.2.0"

"@babel/plugin-proposal-class-properties@^7.0.0":
"@babel/plugin-proposal-class-properties@^7.0.0", "@babel/plugin-proposal-class-properties@^7.3.4":
version "7.3.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.3.4.tgz#410f5173b3dc45939f9ab30ca26684d72901405e"
integrity sha512-lUf8D3HLs4yYlAo8zjuneLvfxN7qfKv1Yzbj5vjqaqMJxgJA3Ipwp4VUJ+OrOdz53Wbww6ahwB8UhB2HQyLotA==
Expand Down