1
1
import linkFiberInitialization from '../routers/linkFiber' ;
2
- import { Snapshot , Status , FiberRoot } from '../types/backendTypes' ;
3
- import Tree from '../models/tree' ;
4
- import { DevTools } from '../types/linkFiberTypes' ;
5
-
6
- import { JSDOM } from 'jsdom' ;
7
- import path from 'path' ;
8
- import fs from 'fs' ;
2
+ import timeJumpInitialization from '../controllers/timeJump' ;
9
3
import componentActionsRecord from '../models/masterState' ;
10
4
import {
11
5
classComponent ,
@@ -14,7 +8,12 @@ import {
14
8
classPayload ,
15
9
updateClassPayload ,
16
10
} from './linkFiber-testcases' ;
17
- import timeJumpInitialization from '../controllers/timeJump' ;
11
+ import { Snapshot , Status , FiberRoot } from '../types/backendTypes' ;
12
+ import Tree from '../models/tree' ;
13
+ import { DevTools } from '../types/linkFiberTypes' ;
14
+ import { JSDOM } from 'jsdom' ;
15
+ import path from 'path' ;
16
+ import fs from 'fs' ;
18
17
19
18
describe ( 'linkFiber' , ( ) => {
20
19
let snapshot : Snapshot ;
@@ -25,14 +24,14 @@ describe('linkFiber', () => {
25
24
let fiberRoot : FiberRoot ;
26
25
let devTools : DevTools ;
27
26
let onCommitFiberRootDelayed : ( resolve : any ) => NodeJS . Timeout ;
28
- const DELAY = 75 ;
27
+ const DELAY = 75 ; //ms
29
28
const mockPostMessage = jest . fn ( ) ;
30
29
let dom : JSDOM ;
31
30
32
- beforeAll ( async ( ) => {
31
+ beforeAll ( ( ) => {
33
32
// Set up a fake DOM environment with JSDOM
34
33
const indexHTML = fs . readFileSync ( path . join ( __dirname , 'index.html' ) , 'utf-8' ) ;
35
- dom = await new JSDOM ( indexHTML , { url : 'http://localhost' } ) ;
34
+ dom = new JSDOM ( indexHTML , { url : 'http://localhost' } ) ;
36
35
global . window = dom . window as unknown as Window & typeof globalThis ;
37
36
global . document = dom . window . _document ;
38
37
@@ -54,11 +53,15 @@ describe('linkFiber', () => {
54
53
jumping : false ,
55
54
paused : false ,
56
55
} ;
57
- // Obtain linkFiber function
56
+
57
+ // Initialize linkFiber
58
58
linkFiber = linkFiberInitialization ( snapshot , mode ) ;
59
59
// Since linkFiber invoke a throttle function that get delay for 70 ms, between each test, linkFiber need to be delayed for 75 ms to ensure no overlapping async calls.
60
60
linkFiberDelayed = ( resolve ) => setTimeout ( async ( ) => resolve ( await linkFiber ( ) ) , DELAY ) ;
61
+
62
+ // Initialize timeJump
61
63
timeJump = timeJumpInitialization ( mode ) ;
64
+
62
65
// Set up mock postMessage function
63
66
window . postMessage = mockPostMessage ;
64
67
0 commit comments