Skip to content

Commit 20e52ab

Browse files
committed
merged with dev
2 parents 0fe9684 + 68817cd commit 20e52ab

17 files changed

+497
-148
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ package/react-time-travel-*.tgz
55
tictactoe
66
parents
77
coverage
8+
src/extension/build.zip

package-lock.json

Lines changed: 33 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@
5252
},
5353
"dependencies": {
5454
"d3": "^3.5.17",
55+
"immer": "^3.2.0",
56+
"jsondiffpatch": "^0.3.11",
5557
"prop-types": "^15.7.2",
5658
"rc-slider": "^8.6.13",
5759
"rc-tooltip": "^3.7.3",
5860
"react": "^16.9.0",
5961
"react-dom": "^16.9.0",
62+
"react-html-parser": "^2.0.2",
6063
"react-json-tree": "^0.11.2",
6164
"react-router-dom": "^5.0.1",
6265
"react-select": "^3.0.4"

src/app/__tests__/ButtonsContainer.test.js

Lines changed: 85 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,107 @@ import { shallow, configure } from 'enzyme';
33
import React from 'react';
44
import Adapter from 'enzyme-adapter-react-16';
55
import ButtonsContainer from '../containers/ButtonsContainer';
6-
6+
import { useStoreContext } from '../store';
7+
import { toggleMode } from '../actions/actions';
78

89
configure({ adapter: new Adapter() });
910

10-
const props = {
11-
toggleMode: jest.fn(),
12-
importSnapshots: jest.fn(),
13-
exportSnapshots: jest.fn(),
14-
mode: {
15-
paused: false,
16-
locked: false,
17-
persist: false,
11+
const state = {
12+
tabs: {
13+
87: {
14+
snapshots: [1, 2, 3, 4],
15+
sliderIndex: 0,
16+
viewIndex: -1,
17+
mode: {
18+
paused: false,
19+
locked: false,
20+
persist: false,
21+
},
22+
},
1823
},
24+
currentTab: 87,
1925
};
2026

21-
describe('testing the bottom buttons', () => {
22-
test('if pause button is invoked', () => {
23-
const wrapper = shallow(<ButtonsContainer {...props} />);
27+
const currentTab = state.tabs[state.currentTab];
2428

25-
wrapper.find('.pause-button').simulate('click');
29+
const dispatch = jest.fn();
2630

27-
expect(props.toggleMode).toHaveBeenCalled();
28-
});
31+
jest.mock('../store');
32+
useStoreContext.mockImplementation(() => [state, dispatch]);
2933

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

33-
wrapper.find('.lock-button').simulate('click');
34-
35-
expect(props.toggleMode).toHaveBeenCalled();
36+
describe('testing the bottom buttons', () => {
37+
beforeEach(() => {
38+
wrapper = shallow(<ButtonsContainer />);
39+
dispatch.mockClear();
40+
useStoreContext.mockClear();
41+
currentTab.mode = {
42+
locked: false,
43+
paused: false,
44+
persist: false,
45+
};
3646
});
3747

38-
test('if persist button is invoked', () => {
39-
const wrapper = shallow(<ButtonsContainer {...props} />);
40-
41-
wrapper.find('.persist-button').simulate('click');
42-
43-
expect(props.toggleMode).toHaveBeenCalled();
48+
describe('pause button testing', () => {
49+
beforeEach(() => {
50+
wrapper.find('.pause-button').simulate('click');
51+
});
52+
test('pause button dispatches upon click', () => {
53+
expect(dispatch.mock.calls.length).toBe(1);
54+
});
55+
56+
test('pause button dispatches toggleMode action', () => {
57+
expect(dispatch.mock.calls[0][0]).toEqual(toggleMode('paused'));
58+
});
59+
60+
test('pause button displays state', () => {
61+
expect(wrapper.find('.pause-button').text()).toBe('Pause');
62+
state.tabs[state.currentTab].mode.paused = true;
63+
wrapper = shallow(<ButtonsContainer />);
64+
expect(wrapper.find('.pause-button').text()).toBe('Resume');
65+
});
4466
});
4567

46-
test('if import button is invoked', () => {
47-
const wrapper = shallow(<ButtonsContainer {...props} />);
48-
49-
wrapper.find('.import-button').simulate('click');
5068

51-
expect(props.importSnapshots).toHaveBeenCalled();
69+
describe('lock button testing', () => {
70+
beforeEach(() => {
71+
wrapper.find('.lock-button').simulate('click');
72+
});
73+
test('lock button dispatches upon click', () => {
74+
expect(dispatch.mock.calls.length).toBe(1);
75+
});
76+
77+
test('lock button dispatches toggleMode action', () => {
78+
expect(dispatch.mock.calls[0][0]).toEqual(toggleMode('locked'));
79+
});
80+
81+
test('lock button displays state', () => {
82+
expect(wrapper.find('.lock-button').text()).toBe('Lock');
83+
state.tabs[state.currentTab].mode.locked = true;
84+
wrapper = shallow(<ButtonsContainer />);
85+
expect(wrapper.find('.lock-button').text()).toBe('Unlock');
86+
});
5287
});
5388

54-
test('if export button is invoked', () => {
55-
const wrapper = shallow(<ButtonsContainer {...props} />);
56-
57-
wrapper.find('.export-button').simulate('click');
58-
59-
expect(props.exportSnapshots).toHaveBeenCalled();
89+
describe('persist button testing', () => {
90+
beforeEach(() => {
91+
wrapper.find('.persist-button').simulate('click');
92+
});
93+
94+
test('persist button dispatches upon click', () => {
95+
expect(dispatch.mock.calls.length).toBe(1);
96+
});
97+
98+
test('persist button dispatches toggleMode action', () => {
99+
expect(dispatch.mock.calls[0][0]).toEqual(toggleMode('persist'));
100+
});
101+
102+
test('persist button displays state', () => {
103+
expect(wrapper.find('.persist-button').text()).toBe('Persist');
104+
state.tabs[state.currentTab].mode.persist = true;
105+
wrapper = shallow(<ButtonsContainer />);
106+
expect(wrapper.find('.persist-button').text()).toBe('Unpersist');
107+
});
60108
});
61109
});

src/app/__tests__/MainContainer.test.js

Whitespace-only changes.

src/app/__tests__/actionContainer.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react/jsx-filename-extension */
22

3-
import { shallow, mount, configure } from 'enzyme';
3+
import { shallow, configure } from 'enzyme';
44
import React from 'react';
55
import Adapter from 'enzyme-adapter-react-16';
66
import ActionContainer from '../containers/ActionContainer';

0 commit comments

Comments
 (0)