Skip to content

Commit 1091f95

Browse files
authored
Merge pull request #43 from oslabs-beta/reactime7
Reactime7
2 parents 770bde9 + b59fb3a commit 1091f95

File tree

11 files changed

+8
-69
lines changed

11 files changed

+8
-69
lines changed

src/app/__tests__/ButtonsContainer.test.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ describe('testing the bottom buttons', () => {
4040
dispatch.mockClear();
4141
useStoreContext.mockClear();
4242
currentTab.mode = {
43-
// locked: false,
4443
paused: false,
4544
persist: false,
4645
};
@@ -65,25 +64,6 @@ describe('testing the bottom buttons', () => {
6564
expect(wrapper.find('.pause-button').text()).toBe('<FontAwesomeIcon />Unlock');
6665
});
6766
});
68-
// describe('lock button testing', () => {
69-
// beforeEach(() => {
70-
// wrapper.find('.lock-button').simulate('click');
71-
// });
72-
// test('lock button dispatches upon click', () => {
73-
// expect(dispatch.mock.calls.length).toBe(1);
74-
// });
75-
76-
// test('lock button dispatches toggleMode action', () => {
77-
// expect(dispatch.mock.calls[0][0]).toEqual(toggleMode('locked'));
78-
// });
79-
80-
// test('lock button displays state', () => {
81-
// expect(wrapper.find('.lock-button').text()).toBe('Lock');
82-
// state.tabs[state.currentTab].mode.locked = true;
83-
// wrapper = shallow(<ButtonsContainer />);
84-
// expect(wrapper.find('.lock-button').text()).toBe('Unlock');
85-
// });
86-
// });
8767

8868
describe('persist button testing', () => {
8969
beforeEach(() => {

src/app/__tests__/MainContainer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ beforeEach(() => {
4848
describe('MainContainer rendering', () => {
4949
test('With no snapshots, should not render any containers', () => {
5050
expect(wrapper.text()).toEqual(
51-
'No React application found. Please visit reactime.io to more info.',
51+
'No React application found. Please visit reactime.io to more info.If you are using a React application, make sure tha you application is running in development mode.NOTE: The React Developer Tools extension is also required for Reactime to run, if you do not already have it installed on your browser.',
5252
);
5353
expect(wrapper.find(HeadContainer).length).toBe(0);
5454
expect(wrapper.find(ActionContainer).length).toBe(0);

src/app/components/Diff.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Diff(props: DiffProps) {
2727
previous = snapshots[sliderIndex - 1];
2828
}
2929

30-
// cleanning preview from stateless data
30+
// cleaning preview from stateless data
3131
const statelessCleanning = (obj:{name?:string; componentData?:object; state?:string|any;stateSnaphot?:object; children?:any[]}) => {
3232
const newObj = { ...obj };
3333
if (newObj.name === 'nameless') {

src/app/components/legend.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ export default function LegendKey(props: any) {
9494
<LegendItem
9595
key={`legend-quantile-${i}`}
9696
margin="0 5px"
97-
onClick={() => {
98-
// if (Event) alert('clicked: YO BRILLIANT GENIUS');
99-
}}
10097
>
10198
<svg width={10} height={10}>
10299
<rect
@@ -122,7 +119,6 @@ export default function LegendKey(props: any) {
122119
width: 25%;
123120
font-family: arial;
124121
font-weight: 900;
125-
// background-color: 242529;
126122
border-radius: 14px;
127123
padding: 2px 2px 2px 2px;
128124
overflow-y: auto;

src/backend/__tests__/timeJump.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
/* eslint-disable max-classes-per-file */
66
import timeJumpRequire from '../timeJump';
77
import componentActionsRecord from '../masterState';
8-
// import { ComponentData } from '../types/backendTypes';
9-
// const timeJumpRequire = require('../timeJump');
108

119
class Component {
1210
mockfn: (state) => void
@@ -65,7 +63,6 @@ describe('unit testing for timeJump.ts', () => {
6563

6664
snapShot = { tree };
6765
timeJump = timeJumpRequire(snapShot, mode);
68-
// mockFunc.mockClear()
6966
});
7067
test('calling the initial require should return a function', () => {
7168
expect(typeof timeJumpRequire).toBe('function');

src/backend/linkFiber.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
//import typescript types
1313
import {
14-
1514
//tree
1615
Snapshot,
1716
//jump, pause
@@ -30,9 +29,7 @@ import componentActionsRecord from './masterState';
3029
// throttle returns a function that can be called any number of times (possibly in quick succession) but will only invoke the callback at most once every x ms
3130
//getHooksNames - helper function to grab the getters/setters from `elementType`
3231
import { throttle, getHooksNames } from './helpers';
33-
// import { Console } from 'console';
3432
import AtomsRelationship from '../app/components/AtomsRelationship';
35-
// import { isNull } from 'util';
3633

3734
// Set global variables to use in exported module and helper functions
3835
declare global {
@@ -116,7 +113,6 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
116113
//updating tree depending on current mode on the panel (pause, etc)
117114
function updateSnapShotTree(snap: Snapshot, mode: Mode): void {
118115
// this is the currently active root fiber(the mutable root of the tree)
119-
120116
if (fiberRoot) {
121117
const { current } = fiberRoot;
122118
//Clears circular component table
@@ -321,12 +317,10 @@ function createTree(
321317
componentData.hooksIndex = hooksIndex;
322318

323319
// Improves tree visualization but breaks jump ?
324-
// if (!newState) {
325-
326-
// }
320+
// if (!newState) {}
327321
// newState.push(state.state);
328322

329-
/* what is this supposed to do??? currently doesn't work?? and makes no sense, newState is an object, how can you push state.state into an object?? */
323+
/* what is this supposed to do? currently doesn't work? and makes no sense, newState is an object, how can you push state.state into an object? */
330324
// if (newState && newState.hooksState) {
331325
// newState.push(state.state);
332326
// } else if (newState) {
@@ -395,7 +389,7 @@ function createTree(
395389

396390
// We want to add this fiber node to the snapshot
397391
if (componentFound || newState === 'stateless') {
398-
// where does this get changed to true?
392+
399393
if (isRecoil) {
400394
// do this down below too
401395
if(currentFiber.elementType.name){
@@ -490,24 +484,19 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
490484
function onVisibilityChange(): void {
491485
doWork = !document.hidden;
492486
}
493-
// this code hasnt changed since reactime 4.0
494-
// https://medium.com/@aquinojardim/react-fiber-reactime-4-0-f200f02e7fa8
495487
return () => {
496488
// react devtools global hook is a global object that was injected by the React Devtools content script, allows access to fiber nodes and react version
497489
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
498490
const reactInstance = devTools ? devTools.renderers.get(1) : null;
499491
fiberRoot = devTools.getFiberRoots(1).values().next().value;
500-
// console.log("fiberRoot in export default: " + Object.entries(fiberRoot));
492+
501493
const throttledUpdateSnapshot = throttle(() => updateSnapShotTree(snap, mode), 70);
502494
document.addEventListener('visibilitychange', onVisibilityChange);
503495

504496
if (reactInstance && reactInstance.version) {
505-
// when is this being called...
506497
devTools.onCommitFiberRoot = (function (original) {
507498
return function (...args) {
508-
// console.log("args in onCommitFiberRoot: ", args)
509499
// eslint-disable-next-line prefer-destructuring
510-
511500
fiberRoot = args[1];
512501
if (doWork) {
513502
throttledUpdateSnapshot();

src/backend/timeJump.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,13 @@ export default (origin, mode) => {
3737
// check if it is a stateful class component
3838
// if yes, find the component by its index and assign it to a variable
3939
// call that components setState method to reset state to the state at the time of the jump snapshot
40-
// if (target.state && !target.state.hooksState)
4140
if (component && component.setState) {
4241
component.setState(
4342
prevState => {
44-
// console.log("prevState: ", prevState);
4543
Object.keys(prevState).forEach(key => {
46-
// console.log("target state object at key: ", target.state[key])
47-
// what is this edge case??
4844
if (!target.state[key] === undefined) {
4945
target.state[key] = undefined;
5046
}
51-
// does this do the same?
52-
// if (!target.state[key]) {
53-
// target.state[key];
54-
// }
5547
});
5648
return target.state;
5749
},
@@ -63,13 +55,11 @@ export default (origin, mode) => {
6355
// Check for hooks state and set it with dispatch()
6456
if (target.state && target.state.hooksState) {
6557
target.state.hooksState.forEach(hook => {
66-
// console.log("hook: ", hook);
6758
const hooksComponent = componentActionsRecord.getComponentByIndex(
6859
target.componentData.hooksIndex,
6960
);
70-
// console.log("hooksComponent: ", hooksComponent);
7161
const hookState = Object.values(hook);
72-
// console.log("hookstate in hooks if block: ", hookState);
62+
7363
if (hooksComponent && hooksComponent.dispatch) {
7464
hooksComponent.dispatch(hookState[0]);
7565
}

src/backend/tree.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class Tree {
6464
}
6565

6666
addChild(state: string | {}, name: string, componentData: {}, rtid: any, recoilDomNode:any): Tree {
67-
//console.log("arguments in addChild: "+ arguments.length)
6867
const newChild: Tree = new Tree(state, name, componentData, rtid, recoilDomNode);
6968
newChild.parent = this;
7069
this.children.push(newChild);

tests/automated-tests/typescript/Frontend/src/scenes/lastSnapshot.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
/* eslint-disable no-undef */
22
import React, { useState, useEffect } from 'react';
3-
// import { connect } from 'react-redux';
43
import './styles.sass';
5-
// import { AnyAction } from 'redux';
6-
7-
// import * as actions from '../redux/actions/actions';
8-
// const mapStateToProps = state => ({});
9-
// const mapDispatchToProps = dispatch => ({});
104

115
const LastSnapshot = () => {
126
const [currentSnapshot, setCurrentSnapshot] = useState('');
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
3-
import reactime from "reactime";
43
import App from "./component/App";
54
import "./index.css";
65
import "github-fork-ribbon-css/gh-fork-ribbon.css";
76

87
ReactDOM.render(<App />, document.getElementById("root"));
9-
// reactime(document.getElementById("root"));
8+

0 commit comments

Comments
 (0)