Skip to content

Commit a9d2e92

Browse files
committed
adding
2 parents 2514a40 + 552697c commit a9d2e92

35 files changed

+672
-11173
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/src/extension/build/

.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

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM node:10.16.2
2+
WORKDIR /usr/src/app
3+
COPY package*.json ./
4+
RUN npm i

babel.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ module.exports = {
88
},
99
},
1010
],
11-
['@babel/preset-react'],
11+
'@babel/preset-react',
1212
],
13-
plugins: [
14-
["@babel/plugin-proposal-decorators", { legacy: true }]
15-
]
1613
};

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
services:
3+
test:
4+
image: reacttt/test-lint
5+
container_name: reacttt-test-lint
6+
volumes:
7+
- .:/usr/src/app
8+
- node_modules:/usr/src/app/node_modules
9+
command: bash -c "npm run lint && npm test"
10+
volumes:
11+
node_modules:

package-lock.json

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

package.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"build": "webpack --mode production",
77
"dev": "webpack --mode development --watch",
88
"test": "jest --verbose --coverage --watchAll",
9-
"lint": "eslint --ext .js --ext .jsx src"
9+
"lint": "eslint --ext .js --ext .jsx src",
10+
"docker-build": "docker build -t reacttt/test-lint .",
11+
"docker-check": "docker-compose up --abort-on-container-exit"
1012
},
1113
"keywords": [
1214
"react",
@@ -25,40 +27,41 @@
2527
"license": "ISC",
2628
"devDependencies": {
2729
"@babel/core": "^7.5.5",
30+
"@babel/plugin-proposal-decorators": "^7.4.4",
2831
"@babel/preset-env": "^7.5.5",
2932
"@babel/preset-react": "^7.0.0",
30-
"@babel/plugin-proposal-decorators": "^7.4.4",
3133
"babel-loader": "^8.0.6",
32-
"css-loader": "^3.1.0",
34+
"css-loader": "^3.2.0",
3335
"enzyme": "^3.10.0",
3436
"enzyme-adapter-react-16": "^1.14.0",
3537
"eslint": "^5.16.0",
3638
"eslint-config-airbnb": "^17.1.1",
37-
"eslint-plugin-import": "^2.18.0",
38-
"eslint-plugin-jest": "^22.13.4",
39+
"eslint-plugin-import": "^2.18.2",
40+
"eslint-plugin-jest": "^22.15.0",
3941
"eslint-plugin-jsx-a11y": "^6.2.3",
40-
"eslint-plugin-react": "^7.14.2",
42+
"eslint-plugin-react": "^7.14.3",
4143
"jest": "^24.8.0",
4244
"jest-cli": "^24.8.0",
4345
"node-sass": "^4.12.0",
44-
"sass-loader": "^7.1.0",
46+
"sass": "^1.22.9",
47+
"sass-loader": "^7.2.0",
4548
"style-loader": "^0.23.1",
46-
"webpack": "^4.36.1",
49+
"webpack": "^4.39.1",
4750
"webpack-chrome-extension-reloader": "^1.3.0",
4851
"webpack-cli": "^3.3.6"
4952
},
5053
"dependencies": {
51-
"auto-bind": "^2.1.0",
5254
"d3": "^3.5.17",
5355
"immer": "^3.2.0",
56+
"jsondiffpatch": "^0.3.11",
5457
"prop-types": "^15.7.2",
5558
"rc-slider": "^8.6.13",
5659
"rc-tooltip": "^3.7.3",
57-
"react": "^16.8.6",
58-
"react-dom": "^16.8.6",
60+
"react": "^16.9.0",
61+
"react-dom": "^16.9.0",
62+
"react-html-parser": "^2.0.2",
5963
"react-json-tree": "^0.11.2",
6064
"react-router-dom": "^5.0.1",
61-
"react-select": "^3.0.4",
62-
"sass": "^1.22.7"
65+
"react-select": "^3.0.4"
6366
}
6467
}

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Two parts are needed for this tool to function. The chrome extension must be ins
1212
```
1313
npm i react-time-travel
1414
```
15-
3. Call the `linkFiber` method on your root container after rendering your App.
15+
3. Call the library method on your root container after rendering your App.
1616

1717
```
18-
const { linkFiber } = require('react-time-travel');
18+
const reactTimeTravel = require('react-time-travel');
1919
2020
const rootContainer = document.getElementById('root');
2121
ReactDom.render(<App />, rootContainer);
2222
23-
linkFiber(rootContainer);
23+
reactTimeTravel(rootContainer);
2424
```
2525

2626
4. Done! That's all you have to do to link your React project to our library.
Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,109 @@
1+
/* eslint-disable react/jsx-filename-extension */
12
import { shallow, configure } from 'enzyme';
23
import React from 'react';
34
import Adapter from 'enzyme-adapter-react-16';
45
import ButtonsContainer from '../containers/ButtonsContainer';
5-
6+
import { useStoreContext } from '../store';
7+
import { toggleMode } from '../actions/actions';
68

79
configure({ adapter: new Adapter() });
810

9-
const props = {
10-
toggleMode: jest.fn(),
11-
importSnapshots: jest.fn(),
12-
exportSnapshots: jest.fn(),
13-
mode: {
14-
paused: false,
15-
locked: false,
16-
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+
},
1723
},
24+
currentTab: 87,
1825
};
1926

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

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

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

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

32-
wrapper.find('.lock-button').simulate('click');
33-
34-
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+
};
3546
});
3647

37-
test('if persist button is invoked', () => {
38-
const wrapper = shallow(<ButtonsContainer {...props} />);
39-
40-
wrapper.find('.persist-button').simulate('click');
41-
42-
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+
});
4366
});
4467

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

50-
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+
});
5187
});
5288

53-
test('if export button is invoked', () => {
54-
const wrapper = shallow(<ButtonsContainer {...props} />);
55-
56-
wrapper.find('.export-button').simulate('click');
57-
58-
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+
});
59108
});
60109
});

src/app/__tests__/MainContainer.test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)