Skip to content

Commit d1198b6

Browse files
committed
eslint configurations made
2 parents f6be551 + 2e18ae9 commit d1198b6

22 files changed

+685
-627
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"build": "webpack --mode production",
77
"dev": "webpack --mode development --watch",
8-
"test": "jest --verbose --coverage --watchAll"
8+
"test": "jest --verbose --coverage --watchAll",
9+
"lint": "eslint --ext .js --ext .jsx src"
910
},
1011
"keywords": [
1112
"react",
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { shallow, configure } from 'enzyme';
2-
32
import React from 'react';
4-
3+
import Adapter from 'enzyme-adapter-react-16';
54
import ButtonsContainer from '../containers/ButtonsContainer';
65

7-
import Adapter from 'enzyme-adapter-react-16';
86

9-
configure({ adapter: new Adapter() })
7+
configure({ adapter: new Adapter() });
108

119
const props = {
1210
toggleMode: jest.fn(),
@@ -17,51 +15,46 @@ const props = {
1715
locked: false,
1816
persist: false,
1917
},
20-
}
18+
};
2119

2220
describe('testing the bottom buttons', () => {
2321
test('if pause button is invoked', () => {
24-
25-
const wrapper = shallow(<ButtonsContainer { ...props } />)
22+
const wrapper = shallow(<ButtonsContainer {...props} />);
2623

2724
wrapper.find('.pause-button').simulate('click');
2825

2926
expect(props.toggleMode).toHaveBeenCalled();
30-
}),
27+
});
3128

3229
test('if lock button is invoked', () => {
33-
34-
const wrapper = shallow(<ButtonsContainer { ...props } />)
30+
const wrapper = shallow(<ButtonsContainer {...props} />);
3531

3632
wrapper.find('.lock-button').simulate('click');
3733

3834
expect(props.toggleMode).toHaveBeenCalled();
39-
}),
35+
});
4036

4137
test('if persist button is invoked', () => {
42-
43-
const wrapper = shallow(<ButtonsContainer { ...props } />)
38+
const wrapper = shallow(<ButtonsContainer {...props} />);
4439

4540
wrapper.find('.persist-button').simulate('click');
4641

4742
expect(props.toggleMode).toHaveBeenCalled();
48-
}),
43+
});
4944

5045
test('if import button is invoked', () => {
51-
52-
const wrapper = shallow(<ButtonsContainer { ...props } />)
46+
const wrapper = shallow(<ButtonsContainer {...props} />);
5347

5448
wrapper.find('.import-button').simulate('click');
5549

5650
expect(props.importSnapshots).toHaveBeenCalled();
57-
}),
51+
});
5852

5953
test('if export button is invoked', () => {
60-
61-
const wrapper = shallow(<ButtonsContainer { ...props } />)
54+
const wrapper = shallow(<ButtonsContainer {...props} />);
6255

6356
wrapper.find('.export-button').simulate('click');
6457

6558
expect(props.exportSnapshots).toHaveBeenCalled();
66-
})
67-
})
59+
});
60+
});
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import { mount , configure } from 'enzyme';
2-
1+
import { mount, configure } from 'enzyme';
32
import React from 'react';
4-
import { MemoryRouter , NavLink } from 'react-router-dom';
5-
3+
import { MemoryRouter, NavLink } from 'react-router-dom';
4+
import Adapter from 'enzyme-adapter-react-16';
65
import StateContainer from '../containers/StateContainer';
76
import Chart from '../components/Chart';
87
import Tree from '../components/Tree';
98

10-
import Adapter from 'enzyme-adapter-react-16';
119

1210
configure({ adapter: new Adapter() });
1311

14-
describe('testing react router path',()=>{
15-
const wrapper = mount(<MemoryRouter><StateContainer/></MemoryRouter>);
16-
it('NavLink has two paths', () => {
12+
describe('testing react router path', () => {
13+
const wrapper = mount(<MemoryRouter><StateContainer /></MemoryRouter>);
14+
it('NavLink has two paths', () => {
1715
expect(wrapper.find(NavLink)).toHaveLength(2);
1816
});
1917
it('First NavLink should be root', () => {
@@ -27,8 +25,9 @@ describe('testing react router path',()=>{
2725
describe('render test', () => {
2826
const wrapper = mount(
2927
<MemoryRouter>
30-
<StateContainer snapshot={ {data :'root'} }/>
31-
</MemoryRouter>);
28+
<StateContainer snapshot={{ data: 'root' }} />
29+
</MemoryRouter>,
30+
);
3231
it('Clicking first NavLink should render Tree only', () => {
3332
wrapper.find(NavLink).at(0).simulate('click', { button: 0 });
3433
expect(wrapper.find(Tree)).toHaveLength(1);
@@ -39,4 +38,4 @@ describe('render test', () => {
3938
expect(wrapper.find(Tree)).toHaveLength(0);
4039
expect(wrapper.find(Chart)).toHaveLength(1);
4140
});
42-
});
41+
});
Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { shallow, configure } from 'enzyme';
2-
32
import React from 'react';
4-
import ReactDOM from 'react-dom';
3+
import Adapter from 'enzyme-adapter-react-16';
54
import TravelContainer from '../containers/TravelContainer';
65
// import MainContainer from '../containers/MainContainer';
7-
import Dropdown from '../components/Dropdown';
6+
// import Dropdown from '../components/Dropdown';
87

9-
import Adapter from 'enzyme-adapter-react-16';
108

11-
configure({ adapter: new Adapter() })
9+
configure({ adapter: new Adapter() });
1210

1311
const props = {
1412
moveBackward: jest.fn(),
@@ -19,23 +17,25 @@ const props = {
1917
snapshotIndex: 6,
2018
play: jest.fn(),
2119
playing: false,
22-
pause: jest.fn()
23-
}
24-
25-
const dropdownProps = {
26-
selectedOption: {
27-
value: 1,
28-
label: 'label'
29-
},
30-
options: [0.5, 1, 2],
31-
onChange: jest.fn(),
32-
}
33-
34-
const options = [
35-
{ value: 2000, label: '0.5x' },
36-
{ value: 1000, label: '1.0x' },
37-
{ value: 500, label: '2.0x' },
38-
];
20+
pause: jest.fn(),
21+
};
22+
23+
// These are fake props to be used during dropdown tests
24+
25+
// const dropdownProps = {
26+
// selectedOption: {
27+
// value: 1,
28+
// label: 'label',
29+
// },
30+
// options: [0.5, 1, 2],
31+
// onChange: jest.fn(),
32+
// };
33+
34+
// const options = [
35+
// { value: 2000, label: '0.5x' },
36+
// { value: 1000, label: '1.0x' },
37+
// { value: 500, label: '2.0x' },
38+
// ];
3939

4040
describe('testing the backward and forward buttons', () => {
4141
test('if the backward button rewinds the playback', () => {
@@ -44,16 +44,16 @@ describe('testing the backward and forward buttons', () => {
4444
wrapper.find('.backward-button').simulate('click');
4545

4646
expect(props.moveBackward).toHaveBeenCalled();
47-
}),
47+
});
4848

4949
test('if the forward button forwards the playback', () => {
5050
const wrapper = shallow(<TravelContainer {...props} />);
5151

5252
wrapper.find('.forward-button').simulate('click');
5353

5454
expect(props.moveForward).toHaveBeenCalled();
55-
})
56-
})
55+
});
56+
});
5757

5858
describe('testing the play button', () => {
5959
test('if the play button starts the playback', () => {
@@ -62,47 +62,43 @@ describe('testing the play button', () => {
6262
wrapper.find('.play-button').simulate('click');
6363

6464
expect(props.play).toHaveBeenCalled();
65-
}),
65+
});
6666

6767
test("if playback is not running, the button should state 'Play'", () => {
6868
const wrapper = shallow(<TravelContainer {...props} />);
6969

7070
wrapper.find('.play-button');
7171

7272
expect(wrapper.find('.play-button').text()).toBe('Play');
73-
}),
73+
});
7474

7575
test("if playback is running, the button should state 'Pause'", () => {
7676
props.playing = true;
77-
77+
7878
const wrapper = shallow(<TravelContainer {...props} />);
7979

8080
wrapper.find('.play-button');
8181

82-
8382
expect(wrapper.find('.play-button').text()).toBe('Pause');
84-
})
85-
})
83+
});
84+
});
8685

8786
describe('testing the playback speed', () => {
8887
test('if the playback dropdown states 0.5x the speed should be 0.5x', () => {
89-
90-
const wrapper = render(<TravelContainer { ...props } />);
88+
const wrapper = shallow(<TravelContainer {...props} />);
9189

9290
wrapper.find('Dropdown').simulate('change', { value: ['val'] });
9391
// wrapper.find('select').simulate('change', { value : 'hello'});
9492
// console.log('val',wrapper.find('Dropdown').simulate('select', { value: ['val'] }));
9593
// expect(wrapper.find('Dropdown').text()).toBe('0.5x')
96-
expect(wrapper.find('select [selected]').val()).to.equal('key')
97-
94+
expect(wrapper.find('select [selected]').val()).toEqual('key');
9895
});
99-
10096
// test('if the playback dropdown states 1x the speed should be 1x', () => {
10197

10298
// const wrapper = shallow(<TravelContainer { ...dropdownProps } />);
10399

104100
// expect(wrapper.find('Dropdown').label).toBe('1.0x')
105-
101+
106102
// });
107103

108104
// test('if the playback dropdown states 2x the speed should be 2x', () => {
@@ -112,6 +108,6 @@ describe('testing the playback speed', () => {
112108
// wrapper.find('Dropdown').simulate('click');
113109

114110
// expect(wrapper.find('Dropdown').label).toBe('2.0x')
115-
111+
116112
// });
117-
})
113+
});
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
import { shallow, configure } from 'enzyme';
2-
32
import React from 'react';
4-
3+
import Adapter from 'enzyme-adapter-react-16';
54
import ActionContainer from '../containers/ActionContainer';
65

7-
import Adapter from 'enzyme-adapter-react-16';
86

9-
configure({ adapter: new Adapter() })
7+
configure({ adapter: new Adapter() });
108

119
const props = {
12-
snapshots: [],
13-
snapshotIndex: 1,
14-
handleChangeSnapshot: jest.fn(),
15-
handleJumpSnapshot: jest.fn(),
16-
emptySnapshot: jest.fn()
17-
}
10+
snapshots: [],
11+
snapshotIndex: 1,
12+
handleChangeSnapshot: jest.fn(),
13+
handleJumpSnapshot: jest.fn(),
14+
emptySnapshot: jest.fn(),
15+
};
1816

1917

2018
describe('testing the emptySnapshot button', () => {
21-
test('emptySnapshot button should be called', () => {
22-
23-
const wrapper = shallow((<ActionContainer { ...props }/>));
19+
test('emptySnapshot button should be called', () => {
20+
const wrapper = shallow((<ActionContainer {...props} />));
2421

2522
wrapper.find('.empty-button').simulate('click');
26-
23+
2724
expect(props.emptySnapshot).toHaveBeenCalled();
2825
});
29-
})
26+
});

src/app/__tests__/dropdown.test.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ import Dropdown from '../components/Dropdown';
66
configure({ adapter: new Adapter() });
77

88
describe('unit testing for Dropdown.jsx', () => {
9-
let wrapper;
10-
const props = {
11-
options: [
12-
{ value: 2000, label: '0.5x' },
13-
{ value: 1000, label: '1.0x' },
14-
{ value: 500, label: '2.0x' },
15-
],
16-
handleChangeSpeed: jest.fn(),
17-
selectedOption: { value: 1000, label: '1.0x' }
18-
};
19-
beforeEach(() => {
20-
wrapper = shallow(<Dropdown {...props} />);
21-
});
9+
let wrapper;
10+
const props = {
11+
options: [
12+
{ value: 2000, label: '0.5x' },
13+
{ value: 1000, label: '1.0x' },
14+
{ value: 500, label: '2.0x' },
15+
],
16+
handleChangeSpeed: jest.fn(),
17+
selectedOption: { value: 1000, label: '1.0x' },
18+
};
19+
beforeEach(() => {
20+
wrapper = shallow(<Dropdown {...props} />);
21+
});
2222

23-
describe('Component', () => {
24-
test('array of objects that have value and label should be options props', () => {
25-
expect(wrapper.props().options).toEqual(props.options);
26-
});
27-
test('selectedOption should be value property', () => {
28-
expect(wrapper.props().value).toEqual(props.selectedOption);
29-
})
30-
})
23+
describe('Component', () => {
24+
test('array of objects that have value and label should be options props', () => {
25+
expect(wrapper.props().options).toEqual(props.options);
26+
});
27+
test('selectedOption should be value property', () => {
28+
expect(wrapper.props().value).toEqual(props.selectedOption);
29+
});
30+
});
3131

32-
describe('handlechangeSpeed', () => {
33-
test('should invoke handleChangeSpeed onChange', () => {
34-
wrapper.simulate('change', { value: 2000, label: '0.5x' });
35-
expect(props.handleChangeSpeed).toHaveBeenCalled();
36-
});
32+
describe('handlechangeSpeed', () => {
33+
test('should invoke handleChangeSpeed onChange', () => {
34+
wrapper.simulate('change', { value: 2000, label: '0.5x' });
35+
expect(props.handleChangeSpeed).toHaveBeenCalled();
3736
});
38-
});
37+
});
38+
});

0 commit comments

Comments
 (0)