Skip to content

Commit decab68

Browse files
committed
update package json & jest dependency
1 parent 12d8aa6 commit decab68

File tree

6 files changed

+1880
-681
lines changed

6 files changed

+1880
-681
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"@types/chrome": "^0.0.119",
111111
"@types/d3": "^7.4.0",
112112
"@types/d3-scale-chromatic": "^2.0.0",
113-
"@types/jest": "^26.0.4",
113+
"@types/jest": "^29.5.0",
114114
"@types/lodash.isequal": "^4.5.5",
115115
"@types/node": "^12.19.6",
116116
"@types/react": "^17.0.43",
@@ -142,12 +142,12 @@
142142
"sass-loader": "^7.3.1",
143143
"sinon-chrome": "^3.0.1",
144144
"style-loader": "^0.23.1",
145-
"ts-jest": "^26.1.2",
146-
"ts-loader": "^7.0.5",
145+
"ts-jest": "^29.0.5",
146+
"ts-loader": "^8.0.0",
147147
"ts-node": "^9.1.1",
148148
"typedoc": "^0.5.0",
149149
"typedoc-webpack-plugin": "^1.1.4",
150-
"typescript": "^5.0.2",
150+
"typescript": "^4.9.0",
151151
"webpack": "^4.43.0",
152152
"webpack-chrome-extension-reloader": "^1.3.0",
153153
"webpack-cli": "^3.3.12"
@@ -192,6 +192,7 @@
192192
"intro.js-react": "^0.6.0",
193193
"jest-runner": "^26.1.0",
194194
"jscharting": "^3.0.2",
195+
"jsdom": "^21.1.1",
195196
"jsondiffpatch": "^0.3.11",
196197
"lodash": "^4.17.21",
197198
"prop-types": "^15.7.2",

src/backend/__tests__/linkFiber.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,33 @@ import updateAndSendSnapShotTree from '../routers/snapShot';
66
import throttle from '../controllers/throttle';
77
import createTree from '../controllers/createTree/createTree';
88
import routes from '../models/routes';
9+
import { JSDOM } from 'jsdom';
910

1011
describe('linkFiber', () => {
1112
let snapShot: Snapshot;
1213
let mode: Status;
1314
let linkFiber;
1415
let fiberRoot: FiberRoot;
1516
const mockPostMessage = jest.fn();
17+
let dom: JSDOM;
18+
beforeAll(() => {
19+
// Set up a fake DOM environment with JSDOM
20+
dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', { url: 'http://localhost' });
21+
global.window = dom.window;
22+
global.document = dom.window._document;
23+
});
24+
25+
afterAll(() => {
26+
// Clean up the fake DOM environment
27+
global.window = undefined;
28+
global.document = undefined;
29+
dom.window.close();
30+
});
31+
beforeEach(() => {
32+
routes = new Routes();
33+
window.history.replaceState = jest.fn();
34+
window.history.pushState = jest.fn();
35+
});
1636

1737
beforeEach(() => {
1838
// Create snapshot and mode objects

src/backend/__tests__/routes.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
import { JSDOM } from 'jsdom';
2+
13
import { Routes, Route } from '../models/routes';
24

35
describe('Route class testing', () => {
46
let routes: Routes;
7+
let dom: JSDOM;
8+
beforeAll(() => {
9+
// Set up a fake DOM environment with JSDOM
10+
dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', { url: 'http://localhost' });
11+
global.window = dom.window;
12+
global.document = dom.window.document;
13+
});
514

15+
afterAll(() => {
16+
// Clean up the fake DOM environment
17+
global.window = undefined;
18+
global.document = undefined;
19+
dom.window.close();
20+
});
621
beforeEach(() => {
722
routes = new Routes();
823
window.history.replaceState = jest.fn();

src/backend/__tests__/tree.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ xdescribe('Tree unit test', () => {
7373
});
7474

7575
xdescribe('Adding children', () => {
76-
const returnChild = newTree.addChild('stateful', 'child', {}, null);
76+
const returnChild: Tree = newTree.addChild('stateful', 'child', {}, null);
7777

7878
it("should have the child be in the children's array property", () => {
7979
// check if returnChild is in the children array property of tree that invoked addChild

src/backend/models/masterState.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
* @function clear - Clears componentActionsRecord
2323
*/
2424
clear: () => {
25-
componentActionsRecord[window.location.href] = [];
25+
componentActionsRecord = [];
2626
index = 0;
2727
},
2828

@@ -32,21 +32,20 @@ export default {
3232
* @returns number
3333
*/
3434
saveNew: (component): number => {
35-
componentActionsRecord[window.location.href].push(component);
35+
componentActionsRecord.push(component);
3636
// componentActionsRecord[index] = component;
3737
// index++;
3838

3939
// return index - 1;
40-
return componentActionsRecord[window.location.href].length - 1;
40+
return componentActionsRecord.length - 1;
4141
},
4242
// ----------------------------CLASS COMPONENT--------------------------------
4343
/**
4444
* @function getComponentByIndex - This function is used for stateful Class Component to retrieve an object that has the bound setState method
4545
* @param inputIndex - index of component inside `componentActionsRecord` coming from `timeJump.ts`
4646
* @returns - an object containing the bound setState method
4747
*/
48-
getComponentByIndex: (inputIndex: number): any | undefined =>
49-
componentActionsRecord[window.location.href][inputIndex],
48+
getComponentByIndex: (inputIndex: number): any | undefined => componentActionsRecord[inputIndex],
5049

5150
//---------------------------FUNCTIONAL COMPONENT-----------------------------
5251
/**
@@ -55,17 +54,15 @@ export default {
5554
* @returns - an array of objects containing the bound dispatch methods
5655
*/
5756
getComponentByIndexHooks: (inputIndex: Array<number> = []): any[] | undefined => {
58-
const validIndex = inputIndex.filter(
59-
(index) => componentActionsRecord[window.location.href]?.[index],
60-
);
57+
const validIndex = inputIndex.filter((index) => componentActionsRecord?.[index]);
6158
if (!validIndex.length) return undefined;
6259

63-
return validIndex.map((index) => componentActionsRecord[window.location.href][index]);
60+
return validIndex.map((index) => componentActionsRecord[index]);
6461
},
6562
// ----------------------------------DEBUGGING--------------------------------
6663
/**
6764
* @function getAllComponents - This method is used for debugging purpose to access the array of setState/dispatch methods
6865
* @returns - an array of objects containing the bound methods for updating state
6966
*/
70-
getAllComponents: (): any[] => componentActionsRecord[window.location.href],
67+
getAllComponents: (): any[] => componentActionsRecord,
7168
};

0 commit comments

Comments
 (0)