Skip to content

Commit 3b166b2

Browse files
committed
create website
2 parents 1ce258c + b4ac425 commit 3b166b2

18 files changed

+118
-19
lines changed

dev-reactime/index.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* 'reactime' module has a single export
3+
* @function linkFiber
4+
*/
5+
import 'core-js';
6+
import 'regenerator-runtime/runtime';
7+
import linkFiberStart from './linkFiber';
8+
import timeJumpStart from './timeJump';
9+
import { Interface } from 'readline';
10+
11+
interface Snapshot{
12+
tree: null;
13+
unfilteredTree: null;
14+
}
15+
16+
interface Mode {
17+
jumping: boolean;
18+
paused: boolean;
19+
locked: boolean;
20+
}
21+
interface Node{
22+
name: string;
23+
state: {
24+
location?: any
25+
}
26+
children: any[]
27+
}
28+
interface Data{
29+
data: {
30+
action: string,
31+
payload: any,
32+
}
33+
}
34+
35+
// * State snapshot object initialized here
36+
const snapShot: Snapshot = {
37+
tree: null,
38+
unfilteredTree: null,
39+
};
40+
41+
const mode: Mode = {
42+
jumping: false,
43+
paused: false,
44+
locked: false,
45+
};
46+
47+
48+
// const linkFiber = require('./linkFiber')(snapShot, mode);
49+
// const timeJump = require('./timeJump')(snapShot, mode);
50+
51+
52+
53+
const linkFiber = linkFiberStart(snapShot, mode);
54+
console.log('linkfiber --> ',linkFiber)
55+
const timeJump = timeJumpStart(snapShot, mode);
56+
console.log('timejump --> ' , timeJump )
57+
58+
59+
function getRouteURL(node: Node): string {
60+
if (node.name === 'Router') {
61+
return node.state.location.pathname;
62+
}
63+
if (node.children && node.children.length >= 1) {
64+
const tempNode: any[] = node.children;
65+
for (let index = 0; index < tempNode.length; index += 1) {
66+
return getRouteURL(tempNode[index]); // Carlos: ???
67+
}
68+
}
69+
}
70+
71+
// * Event listener for time-travel actions
72+
window.addEventListener('message', ({ data: { action, payload } } : Data) => {
73+
switch (action) {
74+
case 'jumpToSnap':
75+
timeJump(payload); // * This sets state with given payload
76+
// Get the pathname from payload and add new entry to browser history
77+
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
78+
79+
// try to modify workInProgress tree from here
80+
window.history.pushState('', '', getRouteURL(payload));
81+
break;
82+
case 'setLock':
83+
mode.locked = payload;
84+
break;
85+
case 'setPause':
86+
mode.paused = payload;
87+
break;
88+
default:
89+
break;
90+
}
91+
});
92+
93+
linkFiber();
94+
95+
// module.exports = linkFiber;
96+
// export default linkFiber;

dev-reactime/module.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module 'core-js';
2+
declare module 'regenerator-runtime/runtime';

src/app/__tests__/actionContainer.test.js renamed to src/app/__tests__/ActionContainer.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useStoreContext } from '../store';
88
import { emptySnapshots } from '../actions/actions';
99
import Action from '../components/Action';
1010

11+
1112
configure({ adapter: new Adapter() });
1213

1314
const state = {

src/app/__tests__/ButtonsContainer.test.js renamed to src/app/__tests__/ButtonsContainer.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe('testing the bottom buttons', () => {
6565
});
6666
});
6767

68-
6968
describe('lock button testing', () => {
7069
beforeEach(() => {
7170
wrapper.find('.lock-button').simulate('click');
@@ -106,4 +105,4 @@ describe('testing the bottom buttons', () => {
106105
expect(wrapper.find('.persist-button').text()).toBe('Unpersist');
107106
});
108107
});
109-
});
108+
});

src/app/__tests__/Chart.test.jsx renamed to src/app/__tests__/Chart.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import React from 'react';
66
import { configure, mount } from 'enzyme';
77
import Adapter from 'enzyme-adapter-react-16';
8-
import Chart from '../components/Chart';
8+
const Chart = require('../components/Chart').default;
9+
910
// Unit test cases for d3 functionality
1011
configure({ adapter: new Adapter() });
1112
// Test the life cycle methods in Chart

src/app/__tests__/Diff.test.jsx renamed to src/app/__tests__/Diff.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { configure, shallow } from 'enzyme';
33
import Adapter from 'enzyme-adapter-react-16';
4-
import Diff from '../components/Diff.jsx';
4+
const Diff = require('../components/Diff').default;
55

66
import { useStoreContext } from '../store';
77

@@ -19,21 +19,21 @@ describe('Unit testing for Diff.jsx', () => {
1919
}],
2020

2121
}],
22-
}
22+
};
2323

2424
const state = {
2525
currentTab: 100,
2626
tabs: { 100: { snapshots: [1, 2, 3, 4], viewIndex: 1, sliderIndex: 1 } },
2727
};
2828

29-
3029
useStoreContext.mockImplementation(() => [state]);
3130

3231
const delta = { children: {} }; // expect delta to be an obj
3332
const html = 'html'; // expect html to be a string
3433
const previous = { state: 'string', children: {} }; // expect previous to be an obj
3534

3635
beforeEach(() => {
36+
// eslint-disable-next-line react/jsx-props-no-spreading
3737
wrapper = shallow(<Diff {...props} />);
3838
});
3939

@@ -69,5 +69,4 @@ describe('Unit testing for Diff.jsx', () => {
6969
expect(wrapper.textContent).not.toEqual('No state change detected. Trigger an event to change state');
7070
});
7171
});
72-
7372
});

src/app/__tests__/DiffRoute.test.jsx renamed to src/app/__tests__/DiffRoute.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Adapter from 'enzyme-adapter-react-16';
44
import {
55
MemoryRouter as Router, Route, NavLink, Switch,
66
} from 'react-router-dom';
7-
8-
import DiffRoute from '../components/DiffRoute.jsx';
7+
const DiffRoute = require('../components/DiffRoute').default;
98

109
const props = {
1110
snapshot: [{}],

src/app/__tests__/SwitchApp.test.jsx renamed to src/app/__tests__/SwitchApp.test.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@ import React from 'react';
22
import Select from 'react-select';
33
import { configure, shallow } from 'enzyme';
44
import Adapter from 'enzyme-adapter-react-16';
5-
import SwitchApp from '../components/SwitchApp.jsx';
5+
import SwitchApp from '../components/SwitchApp';
66

77
import { useStoreContext } from '../store';
88

99
configure({ adapter: new Adapter() });
1010

1111
jest.mock('../store');
1212

13-
1413
describe('Unit testing for SwitchApp.jsx', () => {
1514
let wrapper;
1615

1716
const state = {
1817
currentTab: 100,
19-
tabs: { 100: { snapshots: [1, 2, 3, 4], viewIndex: 1, sliderIndex: 1, title: 'component'} },
18+
tabs: {
19+
100: {
20+
snapshots: [1, 2, 3, 4], viewIndex: 1, sliderIndex: 1, title: 'component',
21+
},
22+
},
2023
};
2124
const dropdownCurrTabLabel = {
2225
value: 100,
@@ -45,7 +48,7 @@ describe('Unit testing for SwitchApp.jsx', () => {
4548
});
4649
it('OnChange should run dispatch function', () => {
4750
expect(dispatch.mock.calls.length).toBe(1);
48-
})
51+
});
4952
it('options prop should be an array', () => {
5053
expect(Array.isArray(wrapper.find('.tab-select-container').props().options)).toBeTruthy();
5154
expect(wrapper.find('.tab-select-container').props().options[0]).toHaveProperty('value');

0 commit comments

Comments
 (0)