Skip to content

Commit b22f8e7

Browse files
Add babel plugin proposal class properties to some example babel config and package files, remove unused constructors with property assignments in react examples, fix prettier errors for same test strings
1 parent 7891983 commit b22f8e7

File tree

9 files changed

+313
-225
lines changed

9 files changed

+313
-225
lines changed

examples/enzyme/.babelrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
module.exports = {
44
presets: ['@babel/preset-env', '@babel/preset-react'],
5+
plugins: ['@babel/plugin-proposal-class-properties']
56
};

examples/enzyme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"devDependencies": {
1010
"@babel/core": "*",
11+
"@babel/plugin-proposal-class-properties": "*",
1112
"@babel/preset-env": "*",
1213
"@babel/preset-react": "*",
1314
"babel-jest": "*",

examples/snapshot/.babelrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
module.exports = {
44
presets: ['@babel/preset-env', '@babel/preset-react'],
5+
plugins: ['@babel/plugin-proposal-class-properties']
56
};

examples/snapshot/Clock.react.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
import React from 'react';
44

55
export default class Clock extends React.Component {
6-
constructor() {
7-
super();
8-
9-
this.state = {seconds: Date.now() / 1000};
10-
}
6+
state = {seconds: Date.now() / 1000};
117

128
componentDidMount() {
139
this.timerID = setInterval(() => this.tick(), 1000);

examples/snapshot/Link.react.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ const STATUS = {
88
};
99

1010
export default class Link extends React.Component {
11-
constructor() {
12-
super();
13-
14-
this.state = {
15-
class: STATUS.NORMAL,
16-
};
17-
}
11+
state = {
12+
class: STATUS.NORMAL,
13+
};
1814

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

examples/snapshot/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"devDependencies": {
99
"@babel/core": "*",
10+
"@babel/plugin-proposal-class-properties": "*",
1011
"@babel/preset-env": "*",
1112
"@babel/preset-react": "*",
1213
"babel-jest": "*",

packages/expect/src/__tests__/__snapshots__/spyMatchers.test.js.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ But the last call returned:
247247
<red>\\"foo\\"</>"
248248
`;
249249

250-
exports[`lastReturnedWith works with three calls 1`] = `
250+
exports[`lastReturnedWith works with three calls (3rd) 1`] = `
251251
"<dim>expect(</><red>jest.fn()</><dim>).not.lastReturnedWith(</><green>expected</><dim>)</>
252252

253253
Expected mock function to not have last returned:
@@ -426,23 +426,23 @@ Expected mock function \\"named-mock\\" first call to have returned with:
426426
But it was <red>not called</>"
427427
`;
428428

429-
exports[`nthReturnedWith incomplete recursive calls are handled properly 1`] = `
429+
exports[`nthReturnedWith incomplete recursive calls are handled properly 1`] = `
430430
"<dim>expect(</><red>jest.fn()</><dim>).nthReturnedWith(</><green>expected</><dim>)</>
431431

432432
Expected mock function first call to have returned with:
433433
<green>6</>
434434
But the first call <red>has not returned yet</>"
435435
`;
436436

437-
exports[`nthReturnedWith incomplete recursive calls are handled properly 2`] = `
437+
exports[`nthReturnedWith incomplete recursive calls are handled properly 2`] = `
438438
"<dim>expect(</><red>jest.fn()</><dim>).nthReturnedWith(</><green>expected</><dim>)</>
439439

440440
Expected mock function second call to have returned with:
441441
<green>3</>
442442
But the second call <red>has not returned yet</>"
443443
`;
444444

445-
exports[`nthReturnedWith incomplete recursive calls are handled properly 3`] = `
445+
exports[`nthReturnedWith incomplete recursive calls are handled properly 3`] = `
446446
"<dim>expect(</><red>jest.fn()</><dim>).not.nthReturnedWith(</><green>expected</><dim>)</>
447447

448448
Expected mock function third call to not have returned with:
@@ -451,7 +451,7 @@ But the third call returned exactly:
451451
<red>1</>"
452452
`;
453453

454-
exports[`nthReturnedWith incomplete recursive calls are handled properly 4`] = `
454+
exports[`nthReturnedWith incomplete recursive calls are handled properly 4`] = `
455455
"<dim>expect(</><red>jest.fn()</><dim>).not.nthReturnedWith(</><green>expected</><dim>)</>
456456

457457
Expected mock function 4th call to not have returned with:
@@ -1625,7 +1625,7 @@ But the last call returned:
16251625
<red>\\"foo\\"</>"
16261626
`;
16271627

1628-
exports[`toHaveLastReturnedWith works with three calls 1`] = `
1628+
exports[`toHaveLastReturnedWith works with three calls (3rd) 1`] = `
16291629
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveLastReturnedWith(</><green>expected</><dim>)</>
16301630

16311631
Expected mock function to not have last returned:
@@ -1667,23 +1667,23 @@ Expected mock function \\"named-mock\\" first call to have returned with:
16671667
But it was <red>not called</>"
16681668
`;
16691669

1670-
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 1`] = `
1670+
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 1`] = `
16711671
"<dim>expect(</><red>jest.fn()</><dim>).toHaveNthReturnedWith(</><green>expected</><dim>)</>
16721672

16731673
Expected mock function first call to have returned with:
16741674
<green>6</>
16751675
But the first call <red>has not returned yet</>"
16761676
`;
16771677

1678-
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 2`] = `
1678+
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 2`] = `
16791679
"<dim>expect(</><red>jest.fn()</><dim>).toHaveNthReturnedWith(</><green>expected</><dim>)</>
16801680

16811681
Expected mock function second call to have returned with:
16821682
<green>3</>
16831683
But the second call <red>has not returned yet</>"
16841684
`;
16851685

1686-
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 3`] = `
1686+
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 3`] = `
16871687
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveNthReturnedWith(</><green>expected</><dim>)</>
16881688

16891689
Expected mock function third call to not have returned with:
@@ -1692,7 +1692,7 @@ But the third call returned exactly:
16921692
<red>1</>"
16931693
`;
16941694

1695-
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 4`] = `
1695+
exports[`toHaveNthReturnedWith incomplete recursive calls are handled properly 4`] = `
16961696
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveNthReturnedWith(</><green>expected</><dim>)</>
16971697

16981698
Expected mock function 4th call to not have returned with:
@@ -2009,7 +2009,7 @@ exports[`toHaveReturnedTimes includes the custom mock name in the error message
20092009
Expected mock function \\"named-mock\\" to have returned <green>one time</>, but it returned <red>two times</>."
20102010
`;
20112011

2012-
exports[`toHaveReturnedTimes incomplete recursive calls are handled properly 1`] = `
2012+
exports[`toHaveReturnedTimes incomplete recursive calls are handled properly (2nd) 1`] = `
20132013
"<dim>expect(</><red>jest.fn()</><dim>).not.toHaveReturnedTimes(</><green>2</><dim>)</>
20142014

20152015
Expected mock function not to have returned <green>two times</>, but it returned exactly <red>two times</>."
@@ -2108,7 +2108,7 @@ Expected mock function \\"named-mock\\" to have returned:
21082108
But it did <red>not return</>."
21092109
`;
21102110

2111-
exports[`toHaveReturnedWith incomplete recursive calls are handled properly 1`] = `
2111+
exports[`toHaveReturnedWith incomplete recursive calls are handled properly (3rd) 1`] = `
21122112
"<dim>expect(</><red>jest.fn()</><dim>).toHaveReturnedWith(</><green>expected</><dim>)</>
21132113

21142114
Expected mock function to have returned:
@@ -2404,7 +2404,7 @@ exports[`toReturnTimes includes the custom mock name in the error message 1`] =
24042404
Expected mock function \\"named-mock\\" to have returned <green>one time</>, but it returned <red>two times</>."
24052405
`;
24062406

2407-
exports[`toReturnTimes incomplete recursive calls are handled properly 1`] = `
2407+
exports[`toReturnTimes incomplete recursive calls are handled properly (2nd) 1`] = `
24082408
"<dim>expect(</><red>jest.fn()</><dim>).not.toReturnTimes(</><green>2</><dim>)</>
24092409

24102410
Expected mock function not to have returned <green>two times</>, but it returned exactly <red>two times</>."
@@ -2503,7 +2503,7 @@ Expected mock function \\"named-mock\\" to have returned:
25032503
But it did <red>not return</>."
25042504
`;
25052505

2506-
exports[`toReturnWith incomplete recursive calls are handled properly 1`] = `
2506+
exports[`toReturnWith incomplete recursive calls are handled properly (3rd) 1`] = `
25072507
"<dim>expect(</><red>jest.fn()</><dim>).toReturnWith(</><green>expected</><dim>)</>
25082508

25092509
Expected mock function to have returned:

packages/expect/src/__tests__/spyMatchers.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ const jestExpect = require('../');
661661
).toThrowErrorMatchingSnapshot();
662662
});
663663

664-
test(`incomplete recursive calls are handled properly`, () => {
664+
test(`incomplete recursive calls are handled properly (2nd)`, () => {
665665
// sums up all integers from 0 -> value, using recursion
666666
const fn = jest.fn(value => {
667667
if (value === 0) {
@@ -892,7 +892,7 @@ const jestExpect = require('../');
892892
}).toThrowErrorMatchingSnapshot();
893893
});
894894

895-
test(`incomplete recursive calls are handled properly`, () => {
895+
test(`incomplete recursive calls are handled properly (3rd)`, () => {
896896
// sums up all integers from 0 -> value, using recursion
897897
const fn = jest.fn(value => {
898898
if (value === 0) {
@@ -988,7 +988,7 @@ const jestExpect = require('../');
988988
}).toThrowErrorMatchingSnapshot();
989989
});
990990

991-
test(`incomplete recursive calls are handled properly`, () => {
991+
test(`incomplete recursive calls are handled properly `, () => {
992992
// sums up all integers from 0 -> value, using recursion
993993
const fn = jest.fn(value => {
994994
if (value === 0) {
@@ -1027,7 +1027,7 @@ const jestExpect = require('../');
10271027

10281028
const lastReturnedWith = ['toHaveLastReturnedWith', 'lastReturnedWith'];
10291029
if (lastReturnedWith.indexOf(returnedWith) >= 0) {
1030-
test(`works with three calls`, () => {
1030+
test(`works with three calls (3rd)`, () => {
10311031
const fn = jest.fn();
10321032
fn.mockReturnValueOnce('foo1');
10331033
fn.mockReturnValueOnce('foo2');

0 commit comments

Comments
 (0)