Skip to content

Commit f636100

Browse files
committed
Update dependencies; Fix linting; Add enzyme adapter;
1 parent ee843c5 commit f636100

File tree

24 files changed

+155
-189
lines changed

24 files changed

+155
-189
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121
},
2222
"rules": {
23+
"function-paren-newline": "off",
2324
"no-param-reassign": "off",
2425
"arrow-parens": [
2526
"error",
@@ -51,7 +52,8 @@
5152
],
5253
"jsx-a11y/aria-props": 2,
5354
"jsx-a11y/heading-has-content": 0,
54-
"jsx-a11y/href-no-hash": 2,
55+
"jsx-a11y/href-no-hash": "off",
56+
"jsx-a11y/anchor-is-valid": "off",
5557
"jsx-a11y/label-has-for": 2,
5658
"jsx-a11y/mouse-events-have-key-events": 2,
5759
"jsx-a11y/role-has-required-aria-props": 2,
@@ -63,6 +65,7 @@
6365
"no-use-before-define": 0,
6466
"prefer-template": 2,
6567
"react/forbid-prop-types": 0,
68+
"react/jsx-curly-brace-presence": "off",
6669
"react/jsx-first-prop-new-line": [
6770
2,
6871
"multiline"

app/components/Button/tests/index.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import Button from '../index';
99

1010
const handleRoute = () => {};
1111
const href = 'http://twitter.com/flexdinesh';
12-
const children = (<h1>Test</h1>);
13-
const renderComponent = (props = {}) => mount(
14-
<Button href={href} {...props}>
15-
{children}
16-
</Button>
17-
);
12+
const children = <h1>Test</h1>;
13+
const renderComponent = (props = {}) =>
14+
mount(
15+
<Button href={href} {...props}>
16+
{children}
17+
</Button>
18+
);
1819

1920
describe('<Button />', () => {
2021
it('should render an <a> tag if no route is specified', () => {

app/components/Footer/tests/index.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import Footer from '../index';
55

66
describe('<Footer />', () => {
77
it('should render the copyright notice', () => {
8-
const renderedComponent = shallow(
9-
<Footer />
10-
);
11-
expect(renderedComponent.contains(
12-
<section>This project is licensed under the MIT license.</section>
13-
)).toBe(true);
8+
const renderedComponent = shallow(<Footer />);
9+
expect(
10+
renderedComponent.contains(
11+
<section>This project is licensed under the MIT license.</section>
12+
)
13+
).toBe(true);
1414
});
1515

1616
it('should render the credits', () => {

app/components/Header/Header.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ class Header extends React.Component { // eslint-disable-line react/prefer-state
1212
<img src={Banner} alt="react-redux-boilerplate - Logo" />
1313
</a>
1414
<div className="nav-bar">
15-
<Link className="router-link" to="/">Home</Link>
16-
<Link className="router-link" to="/features">Features</Link>
15+
<Link className="router-link" to="/">
16+
Home
17+
</Link>
18+
<Link className="router-link" to="/features">
19+
Features
20+
</Link>
1721
</div>
1822
</div>
1923
);

app/components/Header/tests/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import Header from '../index';
55

66
describe('<Header />', () => {
77
it('should render a div', () => {
8-
const renderedComponent = shallow(
9-
<Header />
10-
);
8+
const renderedComponent = shallow(<Header />);
119
expect(renderedComponent.length).toEqual(1);
1210
});
1311
});

app/components/Icons/IssueIcon/tests/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import IssueIcon from '../index';
55

66
describe('<IssueIcon />', () => {
77
it('should render a SVG', () => {
8-
const renderedComponent = shallow(
9-
<IssueIcon />
10-
);
8+
const renderedComponent = shallow(<IssueIcon />);
119
expect(renderedComponent.find('svg').length).toBe(1);
1210
});
1311
});

app/components/List/tests/index.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ import List from '../index';
66

77
describe('<List />', () => {
88
it('should render the component if no items are passed', () => {
9-
const renderedComponent = shallow(
10-
<List component={ListItem} />
11-
);
9+
const renderedComponent = shallow(<List component={ListItem} />);
1210
expect(renderedComponent.find(ListItem)).toBeDefined();
1311
});
1412

1513
it('should pass all items props to rendered component', () => {
16-
const items = [
17-
{ id: 1, name: 'Hello' },
18-
{ id: 2, name: 'World' },
19-
];
14+
const items = [{ id: 1, name: 'Hello' }, { id: 2, name: 'World' }];
2015

2116
const component = ({ item }) => <ListItem>{item.name}</ListItem>; // eslint-disable-line react/prop-types
2217

app/components/ListItem/ListItem.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import './style.scss';
55

66
const ListItem = (props) => (
77
<div className="list-item-wrapper">
8-
<li className="list-item">
9-
{props.item}
10-
</li>
8+
<li className="list-item">{props.item}</li>
119
</div>
12-
);
10+
);
1311

1412
ListItem.propTypes = {
15-
item: PropTypes.any,
13+
item: PropTypes.any
1614
};
1715

1816
export default ListItem;

app/components/ListItem/tests/index.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ describe('<ListItem />', () => {
1010
});
1111

1212
it('should render the content passed to it', () => {
13-
const content = (<div>Hello world!</div>);
14-
const renderedComponent = mount(
15-
<ListItem item={content} />
16-
);
13+
const content = <div>Hello world!</div>;
14+
const renderedComponent = mount(<ListItem item={content} />);
1715
expect(renderedComponent.contains(content)).toBe(true);
1816
});
1917
});

app/components/LoadingIndicator/tests/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import LoadingIndicator from '../index';
55

66
describe('<LoadingIndicator />', () => {
77
it('should render 13 divs', () => {
8-
const renderedComponent = render(
9-
<LoadingIndicator />
10-
);
8+
const renderedComponent = render(<LoadingIndicator />);
119
expect(renderedComponent.length).toBe(1);
1210
});
1311
});

app/components/ReposList/ReposList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const ReposList = ({ loading, error, repos }) => {
2828
ReposList.propTypes = {
2929
loading: PropTypes.bool,
3030
error: PropTypes.any,
31-
repos: PropTypes.any,
31+
repos: PropTypes.any
3232
};
3333

3434
export default ReposList;

app/components/ReposList/tests/index.test.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,45 @@ import ReposList from '../index';
88

99
describe('<ReposList />', () => {
1010
it('should render the loading indicator when its loading', () => {
11-
const renderedComponent = shallow(
12-
<ReposList loading />
13-
);
14-
expect(renderedComponent.contains(<List component={LoadingIndicator} />)).toEqual(true);
11+
const renderedComponent = shallow(<ReposList loading />);
12+
expect(
13+
renderedComponent.contains(<List component={LoadingIndicator} />)
14+
).toEqual(true);
1515
});
1616

1717
it('should render an error if loading failed', () => {
1818
const renderedComponent = mount(
19-
<ReposList
20-
loading={false}
21-
error={{ message: 'Loading failed!' }}
22-
/>
19+
<ReposList loading={false} error={{ message: 'Loading failed!' }} />
2320
);
2421
expect(renderedComponent.text()).toMatch(/Something went wrong/);
2522
});
2623

2724
it('should render the repositories if loading was successful', () => {
28-
const repos = [{
29-
owner: {
30-
login: 'flexdinesh',
31-
},
32-
html_url: 'https://github.com/flexdinesh/react-redux-boilerplate',
33-
name: 'react-redux-boilerplate',
34-
open_issues_count: 20,
35-
full_name: 'flexdinesh/react-redux-boilerplate',
36-
}];
25+
const repos = [
26+
{
27+
owner: {
28+
login: 'flexdinesh'
29+
},
30+
html_url: 'https://github.com/flexdinesh/react-redux-boilerplate',
31+
name: 'react-redux-boilerplate',
32+
open_issues_count: 20,
33+
full_name: 'flexdinesh/react-redux-boilerplate'
34+
}
35+
];
3736
const renderedComponent = shallow(
38-
<ReposList
39-
repos={repos}
40-
error={false}
41-
/>
37+
<ReposList repos={repos} error={false} />
4238
);
4339

44-
expect(renderedComponent.contains(<List items={repos} component={RepoListItem} />)).toEqual(true);
40+
expect(
41+
renderedComponent.contains(
42+
<List items={repos} component={RepoListItem} />
43+
)
44+
).toEqual(true);
4545
});
4646

4747
it('should not render anything if nothing interesting is provided', () => {
4848
const renderedComponent = shallow(
49-
<ReposList
50-
repos={false}
51-
error={false}
52-
loading={false}
53-
/>
49+
<ReposList repos={false} error={false} loading={false} />
5450
);
5551

5652
expect(renderedComponent.html()).toEqual(null);

app/containers/App/tests/index.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@ import App from '../index';
88

99
describe('<App />', () => {
1010
it('should render the header', () => {
11-
const renderedComponent = shallow(
12-
<App />
13-
);
11+
const renderedComponent = shallow(<App />);
1412
expect(renderedComponent.find(Header).length).toBe(1);
1513
});
1614

1715
it('should render some routes', () => {
18-
const renderedComponent = shallow(
19-
<App />
20-
);
16+
const renderedComponent = shallow(<App />);
2117
expect(renderedComponent.find(Route).length).not.toBe(0);
2218
});
2319

2420
it('should render the footer', () => {
25-
const renderedComponent = shallow(
26-
<App />
27-
);
21+
const renderedComponent = shallow(<App />);
2822
expect(renderedComponent.find(Footer).length).toBe(1);
2923
});
3024
});

app/containers/FeaturePage/tests/index.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ import FeaturePage from '../index';
55

66
describe('<FeaturePage />', () => {
77
it('should render its heading', () => {
8-
const renderedComponent = shallow(
9-
<FeaturePage />
10-
);
11-
expect(renderedComponent.contains(
12-
<h1>Features</h1>
13-
)).toBe(true);
8+
const renderedComponent = shallow(<FeaturePage />);
9+
expect(renderedComponent.contains(<h1>Features</h1>)).toBe(true);
1410
});
1511

1612
it('should never re-render the component', () => {
17-
const renderedComponent = shallow(
18-
<FeaturePage />
19-
);
13+
const renderedComponent = shallow(<FeaturePage />);
2014
const inst = renderedComponent.instance();
2115
expect(inst.shouldComponentUpdate()).toBe(false);
2216
});

app/containers/HomePage/actions.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
* }
1616
*/
1717

18-
import {
19-
CHANGE_USERNAME,
20-
} from './constants';
18+
import { CHANGE_USERNAME } from './constants';
2119

2220
/**
2321
* Changes the input field of the form
@@ -29,6 +27,6 @@ import {
2927
export function changeUsername(name) {
3028
return {
3129
type: CHANGE_USERNAME,
32-
name,
30+
name
3331
};
3432
}

app/containers/HomePage/reducer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,18 @@
1111
*/
1212
import { fromJS } from 'immutable';
1313

14-
import {
15-
CHANGE_USERNAME,
16-
} from './constants';
14+
import { CHANGE_USERNAME } from './constants';
1715

1816
// The initial state of the App
1917
const initialState = fromJS({
20-
username: '',
18+
username: ''
2119
});
2220

2321
function homeReducer(state = initialState, action) {
2422
switch (action.type) {
2523
case CHANGE_USERNAME:
26-
2724
// Delete prefixed '@' from the github username
28-
return state
29-
.set('username', action.name.replace(/@/gi, ''));
25+
return state.set('username', action.name.replace(/@/gi, ''));
3026
default:
3127
return state;
3228
}

app/containers/HomePage/tests/actions.test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import {
2-
CHANGE_USERNAME,
3-
} from '../constants';
1+
import { CHANGE_USERNAME } from '../constants';
42

5-
import {
6-
changeUsername,
7-
} from '../actions';
3+
import { changeUsername } from '../actions';
84

95
describe('Home Actions', () => {
106
describe('changeUsername', () => {
117
it('should return the correct type and the passed name', () => {
128
const fixture = 'Max';
139
const expectedResult = {
1410
type: CHANGE_USERNAME,
15-
name: fixture,
11+
name: fixture
1612
};
1713

1814
expect(changeUsername(fixture)).toEqual(expectedResult);

app/containers/HomePage/tests/index.test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ describe('<HomePage />', () => {
1616
const renderedComponent = shallow(
1717
<HomePage loading error={false} repos={[]} />
1818
);
19-
expect(renderedComponent.contains(<ReposList loading error={false} repos={[]} />)).toEqual(true);
19+
expect(
20+
renderedComponent.contains(<ReposList loading error={false} repos={[]} />)
21+
).toEqual(true);
2022
});
2123

2224
it('should render fetch the repos on mount if a username exists', () => {
@@ -33,12 +35,7 @@ describe('<HomePage />', () => {
3335

3436
it('should not call onSubmitForm if username is an empty string', () => {
3537
const submitSpy = jest.fn();
36-
mount(
37-
<HomePage
38-
onChangeUsername={() => {}}
39-
onSubmitForm={submitSpy}
40-
/>
41-
);
38+
mount(<HomePage onChangeUsername={() => {}} onSubmitForm={submitSpy} />);
4239
expect(submitSpy).not.toHaveBeenCalled();
4340
});
4441

0 commit comments

Comments
 (0)