Skip to content

Commit 9d742c8

Browse files
committed
tests cleaned up
2 parents e8f91a9 + ccff073 commit 9d742c8

26 files changed

+1966
-1233
lines changed

.eslintrc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
{
22
"extends": ["airbnb", "plugin:jest/recommended"],
33
"root": true,
4-
"plugins": ["jest"],
4+
"plugins": ["jest", "react"],
5+
"rules": {
6+
"arrow-parens": [2, "as-needed"]
7+
},
58
"env": {
9+
"es6": true,
610
"jest/globals": true,
711
"browser": true,
812
"webextensions": true
913
},
1014
"globals": {
15+
"Atomics": "readonly",
16+
"SharedArrayBuffer": "readonly",
1117
"fetch": false
1218
},
13-
"rules": {
14-
"arrow-parens": [2, "as-needed"]
19+
"parserOptions": {
20+
"ecmaFeatures": {
21+
"jsx": true
22+
},
23+
"ecmaVersion": 2018,
24+
"sourceType": "module"
25+
},
26+
"settings": {
27+
"import/no-unresolved": "off"
1528
}
16-
}
29+
}

package-lock.json

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

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@
4343
"css-loader": "^3.2.0",
4444
"enzyme": "^3.10.0",
4545
"enzyme-adapter-react-16": "^1.14.0",
46-
"eslint": "^5.16.0",
47-
"eslint-config-airbnb": "^17.1.1",
46+
"eslint": "^6.5.1",
47+
"eslint-config-airbnb": "^18.0.1",
4848
"eslint-plugin-import": "^2.18.2",
4949
"eslint-plugin-jest": "^22.15.0",
5050
"eslint-plugin-jsx-a11y": "^6.2.3",
51-
"eslint-plugin-react": "^7.14.3",
52-
"jest": "^24.8.0",
51+
"eslint-plugin-react": "^7.15.1",
52+
"eslint-plugin-react-hooks": "^1.7.0",
53+
"jest": "^24.9.0",
5354
"jest-cli": "^24.8.0",
55+
"jest-runner-eslint": "^0.7.4",
5456
"node-sass": "^4.12.0",
5557
"sass": "^1.22.9",
5658
"sass-loader": "^7.2.0",
@@ -66,6 +68,7 @@
6668
"d3-tip": "^0.9.1",
6769
"d3-zoom": "^1.8.3",
6870
"immer": "^3.2.0",
71+
"jest-runner": "^24.9.0",
6972
"jsondiffpatch": "^0.3.11",
7073
"prop-types": "^15.7.2",
7174
"rc-slider": "^8.6.13",

package/__tests__/astParser.test.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Test 1: Should take in a function definition with 1 hook and return an object with the getter/setter
1+
// import { configure, shallow } from 'enzyme';
2+
3+
// Test 1: Should take in a function definition with 1 hook
4+
// and return an object with the getter / setter
25
// EXAMPLE INPUT FOR TEST
36
/**
47
* function UseStateHookTest() {
@@ -22,7 +25,14 @@
2225
* }
2326
*/
2427

25-
// TEST 2: Should take in multiple function definitions with hooks and return an object with all 4 properties
26-
// TEST 3: Should ignore any non-hook definitions
27-
// Test 4: Should return an empty object if no hooks found
28-
// Test 5: Should throw an error if input is invalid javascript
28+
// TEST 2: Should take in multiple function definitions
29+
// with hooks and return an object with all 4 properties
30+
// TEST 3: Should ignore any non-hook definitions
31+
// Test 4: Should return an empty object if no hooks found
32+
// Test 5: Should throw an error if input is invalid javascript
33+
34+
describe('placeholder', () => {
35+
it.skip('placeholder for tests', () => {
36+
expect(1 + 1).toEqual(2);
37+
});
38+
});

package/__tests__/linkFiber.test.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable react/jsx-filename-extension */
2-
import React, { Component, useState } from 'react';
2+
import React, { Component } from 'react';
33
import { render } from 'react-dom';
44

55
const linkFiberRequire = require('../linkFiber');
@@ -20,17 +20,6 @@ class App extends Component {
2020
}
2121
}
2222

23-
// Need to create a functioanl component instance to test
24-
// Would need to be revised but here's the gist
25-
// const funcComponent = () => {
26-
// const [ number, setNumber ] = useState(0);
27-
// const newNumber = setNumber(1);
28-
29-
// return (
30-
// <div>{newNumber}</div>
31-
// )
32-
// }
33-
3423
describe('unit test for linkFiber', () => {
3524
beforeEach(() => {
3625
snapShot = { tree: null };

package/__tests__/timeJump.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-classes-per-file */
12
const timeJumpRequire = require('../timeJump');
23

34
class Component {
@@ -19,10 +20,6 @@ class FiberNode {
1920
}
2021
}
2122

22-
// MVP FEATURE: Additional Testing
23-
// Testing for useState and useContext
24-
25-
2623
describe('unit testing for timeJump.js', () => {
2724
let timeJump;
2825
let snapShot;

package/astParser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
const acorn = require('acorn');
22
const jsx = require('acorn-jsx');
3+
34
const JSXParser = acorn.Parser.extend(jsx());
45

56
// Helper function to grab the getters/setters from `elementType`
67
module.exports = elementType => {
78
// Initialize empty object to store the setters and getter
8-
let ast = JSXParser.parse(elementType);
9+
let ast = JSXParser.parse(elementType);
910
const hookState = {};
1011
// All module exports will always start off as a single 'FunctionDeclaration' type
1112
while (Object.hasOwnProperty.call(ast, 'body')) {
@@ -34,4 +35,4 @@ module.exports = elementType => {
3435
});
3536
}
3637
return hookState;
37-
}
38+
};

package/linkFiber.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = (snap, mode) => {
1313

1414
function sendSnapshot() {
1515
// don't send messages while jumping or while paused
16-
// DEV: So that when we are jumping to an old snapshot it wouldn't think we want to create new snapshots
16+
// DEV: So that when we are jumping to an old snapshot it
17+
// wouldn't think we want to create new snapshots
1718
if (mode.jumping || mode.paused) return;
1819
const payload = snap.tree.getCopy();
1920
// console.log('payload', payload);
@@ -83,7 +84,7 @@ module.exports = (snap, mode) => {
8384

8485
function createTree(currentFiber, tree = new Tree('root')) {
8586
if (!currentFiber) return tree;
86-
87+
8788
const {
8889
sibling,
8990
stateNode,
@@ -103,9 +104,9 @@ module.exports = (snap, mode) => {
103104
// Check if the component uses hooks
104105
if (memoizedState && Object.hasOwnProperty.call(memoizedState, 'baseState')) {
105106
// Traverse through the currentFiber and extract the getters/setters
106-
astHooks = astParser(elementType);
107-
saveState(astHooks);
108-
// Create a traversed property and assign to the evaluated result of
107+
astHooks = astParser(elementType);
108+
saveState(astHooks);
109+
// Create a traversed property and assign to the evaluated result of
109110
// invoking traverseHooks with memoizedState
110111
memoizedState.traversed = traverseHooks(memoizedState);
111112
nextTree = tree.appendChild(memoizedState);
@@ -131,7 +132,7 @@ module.exports = (snap, mode) => {
131132
} = container;
132133
// only assign internal rootp if it actually exists
133134
fiberRoot = _internalRoot || _reactRootContainer;
134-
135+
135136
updateSnapShotTree();
136137
// send the initial snapshot once the content script has started up
137138
window.addEventListener('message', ({ data: { action } }) => {
@@ -145,5 +146,5 @@ module.exports = (snap, mode) => {
145146
// return getNextImport('./UseStateHook');
146147
// return 'Testing outside';
147148
// const OtherComponent = loadable(() => import('./OtherComponent'))
148-
}
149-
};
149+
};
150+
};

package/tree.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Tree {
3030
getCopy(copy = new Tree('root', true)) {
3131
// copy state of children
3232
copy.children = this.children.map(
33-
child => new Tree(child.component.state || child.component.traversed, true, child.component.constructor.name),
33+
child => new Tree(child.component.state
34+
|| child.component.traversed, true, child.component.constructor.name),
3435
);
3536

3637
// copy children's children recursively
@@ -40,8 +41,8 @@ class Tree {
4041

4142
// print out the tree in the console
4243
// DEV: Process may be different for useState components
43-
// BUG FIX: Don't print the Router as a component
44-
// Change how the children are printed
44+
// BUG FIX: Don't print the Router as a component
45+
// Change how the children are printed
4546
print() {
4647
const children = ['children: '];
4748
// DEV: What should we push instead for components using hooks (it wouldn't be state)

src/app/__tests__/Chart.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ describe('tooltip functionality in maked3Tree', () => {
4949

5050

5151

52-
52+

0 commit comments

Comments
 (0)