Skip to content

Commit 8fd4f94

Browse files
authored
Merge pull request #62 from oslabs-beta/sierra
eslint modifications made
2 parents 2e18ae9 + d1198b6 commit 8fd4f94

File tree

7 files changed

+127
-89
lines changed

7 files changed

+127
-89
lines changed
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: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { shallow, configure } from 'enzyme';
2-
32
import React from 'react';
4-
3+
import Adapter from 'enzyme-adapter-react-16';
54
import TravelContainer from '../containers/TravelContainer';
5+
// import MainContainer from '../containers/MainContainer';
6+
// import Dropdown from '../components/Dropdown';
67

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

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

1111
const props = {
1212
moveBackward: jest.fn(),
@@ -17,8 +17,25 @@ const props = {
1717
snapshotIndex: 6,
1818
play: jest.fn(),
1919
playing: false,
20-
pause: jest.fn()
21-
}
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+
// ];
2239

2340
describe('testing the backward and forward buttons', () => {
2441
test('if the backward button rewinds the playback', () => {
@@ -27,16 +44,16 @@ describe('testing the backward and forward buttons', () => {
2744
wrapper.find('.backward-button').simulate('click');
2845

2946
expect(props.moveBackward).toHaveBeenCalled();
30-
}),
47+
});
3148

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

3552
wrapper.find('.forward-button').simulate('click');
3653

3754
expect(props.moveForward).toHaveBeenCalled();
38-
})
39-
})
55+
});
56+
});
4057

4158
describe('testing the play button', () => {
4259
test('if the play button starts the playback', () => {
@@ -45,24 +62,52 @@ describe('testing the play button', () => {
4562
wrapper.find('.play-button').simulate('click');
4663

4764
expect(props.play).toHaveBeenCalled();
48-
}),
65+
});
4966

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

5370
wrapper.find('.play-button');
5471

5572
expect(wrapper.find('.play-button').text()).toBe('Play');
56-
}),
73+
});
5774

5875
test("if playback is running, the button should state 'Pause'", () => {
5976
props.playing = true;
60-
77+
6178
const wrapper = shallow(<TravelContainer {...props} />);
6279

6380
wrapper.find('.play-button');
6481

65-
6682
expect(wrapper.find('.play-button').text()).toBe('Pause');
67-
})
68-
})
83+
});
84+
});
85+
86+
describe('testing the playback speed', () => {
87+
test('if the playback dropdown states 0.5x the speed should be 0.5x', () => {
88+
const wrapper = shallow(<TravelContainer {...props} />);
89+
90+
wrapper.find('Dropdown').simulate('change', { value: ['val'] });
91+
// wrapper.find('select').simulate('change', { value : 'hello'});
92+
// console.log('val',wrapper.find('Dropdown').simulate('select', { value: ['val'] }));
93+
// expect(wrapper.find('Dropdown').text()).toBe('0.5x')
94+
expect(wrapper.find('select [selected]').val()).toEqual('key');
95+
});
96+
// test('if the playback dropdown states 1x the speed should be 1x', () => {
97+
98+
// const wrapper = shallow(<TravelContainer { ...dropdownProps } />);
99+
100+
// expect(wrapper.find('Dropdown').label).toBe('1.0x')
101+
102+
// });
103+
104+
// test('if the playback dropdown states 2x the speed should be 2x', () => {
105+
106+
// const wrapper = shallow(<TravelContainer { ...dropdownProps } />);
107+
108+
// wrapper.find('Dropdown').simulate('click');
109+
110+
// expect(wrapper.find('Dropdown').label).toBe('2.0x')
111+
112+
// });
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+
});

src/app/components/Dropdown.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const Dropdown = (props) => {
1515
/>
1616
);
1717
};
18+
1819
Dropdown.propTypes = {
1920
selectedSpeed: PropTypes.shape({ value: PropTypes.number, label: PropTypes.string }).isRequired,
2021
speeds: PropTypes.arrayOf(PropTypes.object).isRequired,

src/extension/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
103103

104104
const { persist } = tabsObj[tabId].mode;
105105

106+
console.log('request: ', request)
107+
console.log('sender: ', sender)
108+
106109
switch (action) {
107110
case 'tabReload':
108111
tabsObj[tabId].firstSnapshot = true;

0 commit comments

Comments
 (0)