Skip to content

Commit c78fcd2

Browse files
authored
Merge pull request #97 from oslabs-beta/rydang/testing
linting packages now
2 parents 03ceaff + ccfb7f5 commit c78fcd2

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"lint": "eslint --ext .js --ext .jsx src",
99
"docker-build": "docker build -t reacttt/test-lint .",
1010
"docker-check": "docker-compose up --abort-on-container-exit",
11-
"docker-test-lint": "eslint --ext .js --ext .jsx src && jest --verbose"
11+
"docker-test-lint": "eslint --ext .js --ext .jsx src package && jest --verbose"
1212
},
1313
"keywords": [
1414
"react",

package/__tests__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('unit testing for index.js', () => {
1111
expect(typeof index).toBe('function');
1212
});
1313

14-
test('index.js should be calling timeJump for every jumpToSnap message', (done) => {
14+
test('index.js should be calling timeJump for every jumpToSnap message', done => {
1515
const calls = 10;
1616
let count = 0;
1717
global.addEventListener('message', ({ data: { action } }) => {

package/__tests__/linkFiber.test.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
2-
// const Tree = require('./tree');
1+
/* eslint-disable react/jsx-filename-extension */
32
import React from 'react';
43
import { render } from 'react-dom';
54

@@ -8,7 +7,18 @@ const linkFiberRequire = require('../linkFiber');
87
let linkFiber;
98
let mode;
109
let snapShot;
11-
let component;
10+
11+
class App extends React.Component {
12+
constructor(props) {
13+
super(props);
14+
this.state = { foo: 'bar' };
15+
}
16+
17+
render() {
18+
const { foo } = this.state;
19+
return <div>{foo}</div>;
20+
}
21+
}
1222

1323
describe('unit test for linkFiber', () => {
1424
beforeEach(() => {
@@ -20,22 +30,9 @@ describe('unit test for linkFiber', () => {
2030
};
2131
linkFiber = linkFiberRequire(snapShot, mode);
2232

23-
class App extends React.Component {
24-
constructor(props) {
25-
super(props);
26-
this.state = { foo: 'bar' };
27-
}
28-
29-
render() {
30-
return <div>{this.state.foo}</div>;
31-
}
32-
}
33-
3433
const container = document.createElement('div');
3534
render(<App />, container);
3635
linkFiber(container);
37-
// eslint-disable-next-line prefer-destructuring
38-
component = snapShot.tree.children[0].component;
3936
});
4037

4138
test('linkFiber should mutate the snapshot tree property', () => {
@@ -49,10 +46,4 @@ describe('unit test for linkFiber', () => {
4946
test('linkFiber should modify the setState of the stateful component', () => {
5047
expect(snapShot.tree.children[0].component.setState.linkFiberChanged).toBe(true);
5148
});
52-
53-
// test('newSetState should still setState correctly', () => {
54-
// component.setState({ foo: 'barf' });
55-
// expect(component.state).not.toEqual({ foo: 'bar' });
56-
// expect(component.state).toEqual({ foo: 'barf' });
57-
// });
5849
});

package/linkFiber.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-use-before-define */
2+
/* eslint-disable no-param-reassign */
13
// links component state tree to library
24
// changes the setState method to also update our snapshot
35
const Tree = require('./tree');
@@ -65,13 +67,13 @@ module.exports = (snap, mode) => {
6567
snap.tree = createTree(current);
6668
}
6769

68-
return (container) => {
70+
return container => {
6971
const {
7072
_reactRootContainer: { _internalRoot },
7173
_reactRootContainer,
7274
} = container;
7375
// only assign internal root if it actually exists
74-
fiberRoot = (_internalRoot) ? _internalRoot : _reactRootContainer;
76+
fiberRoot = _internalRoot || _reactRootContainer;
7577
updateSnapShotTree();
7678

7779
// send the initial snapshot once the content script has started up

package/tree.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable no-param-reassign */
13
class Tree {
24
constructor(component, useStateInstead = false, name) {
35
// special case when component is root

0 commit comments

Comments
 (0)