Skip to content

Commit

Permalink
Add babel plugin proposal class properties to some example babel conf…
Browse files Browse the repository at this point in the history
…ig and package files, remove unused constructors with property assignments in react examples, fix prettier errors for same test strings
  • Loading branch information
peanutenthusiast committed Mar 13, 2019
1 parent 7891983 commit b22f8e7
Show file tree
Hide file tree
Showing 9 changed files with 313 additions and 225 deletions.
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']
};
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/snapshot/.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']
};
6 changes: 1 addition & 5 deletions examples/snapshot/Clock.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import React from 'react';

export default class Clock extends React.Component {
constructor() {
super();

this.state = {seconds: Date.now() / 1000};
}
state = {seconds: Date.now() / 1000};

componentDidMount() {
this.timerID = setInterval(() => this.tick(), 1000);
Expand Down
10 changes: 3 additions & 7 deletions examples/snapshot/Link.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ const STATUS = {
};

export default class Link extends React.Component {
constructor() {
super();

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

_onMouseEnter = () => {
this.setState({class: STATUS.HOVERED});
Expand Down
1 change: 1 addition & 0 deletions examples/snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"devDependencies": {
"@babel/core": "*",
"@babel/plugin-proposal-class-properties": "*",
"@babel/preset-env": "*",
"@babel/preset-react": "*",
"babel-jest": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ But the last call returned:
<red>\\"foo\\"</>"
`;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Expected mock function to have returned:
Expand Down
8 changes: 4 additions & 4 deletions packages/expect/src/__tests__/spyMatchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ const jestExpect = require('../');
).toThrowErrorMatchingSnapshot();
});

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

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

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

const lastReturnedWith = ['toHaveLastReturnedWith', 'lastReturnedWith'];
if (lastReturnedWith.indexOf(returnedWith) >= 0) {
test(`works with three calls`, () => {
test(`works with three calls (3rd)`, () => {
const fn = jest.fn();
fn.mockReturnValueOnce('foo1');
fn.mockReturnValueOnce('foo2');
Expand Down
Loading

0 comments on commit b22f8e7

Please sign in to comment.