Skip to content

Commit 0acfe23

Browse files
Zachary FreemanZachary Freeman
authored andcommitted
progress on timeJump tests
1 parent 248789b commit 0acfe23

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/backend/__tests__/timeJump.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
import timeJumpInitiation from '../controllers/timeJump';
2+
import { Status } from '../types/backendTypes';
3+
import Tree from '../models/tree';
4+
5+
describe('timeJumpInitiation', () => {
6+
const mockMode: Status = { jumping: false, paused: true };
7+
const mockTreeSnapshot: Tree = new Tree({});
8+
9+
beforeEach(() => {
10+
// Reset mode before each test
11+
mockMode.jumping = false;
12+
});
13+
14+
it('should return a function that updates the React Fiber Tree based on the target snapshot', async () => {
15+
// Call timeJumpInitiation and get the returned function
16+
const timeJump = timeJumpInitiation(mockMode);
17+
expect(typeof timeJump).toBe('function');
18+
19+
// Call the returned function with the mock target snapshot
20+
await timeJump(mockTreeSnapshot);
21+
22+
// Assert that the mode's jumping property is true
23+
expect(mockMode.jumping).toBe(true);
24+
});
25+
26+
it('should reset the jumping mode to false when the mouse is over the browser', async () => {
27+
// Call timeJumpInitiation and get the returned function
28+
const timeJump = timeJumpInitiation(mockMode);
29+
expect(typeof timeJump).toBe('function');
30+
31+
// Call the returned function with the mock target snapshot
32+
await timeJump(mockTreeSnapshot);
33+
34+
// Simulate mouseover event
35+
window.dispatchEvent(new MouseEvent('mouseover'));
36+
37+
// Assert that the mode's jumping property is false
38+
expect(mockMode.jumping).toBe(false);
39+
});
40+
});
41+
142
// import timeJumpRequire from '../timeJump';
243
// import componentActionsRecord from '../masterState';
344

src/backend/controllers/timeJump.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import routes from '../models/routes';
2-
3-
/* eslint-disable @typescript-eslint/no-unused-vars */
4-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
5-
/* eslint-disable max-len */
6-
/* eslint-disable no-param-reassign */
71
import componentActionsRecord from '../models/masterState';
82
import { Status } from '../types/backendTypes';
93
import Tree from '../models/tree';
@@ -30,6 +24,7 @@ export default function timeJumpInitiation(mode: Status) {
3024
* @param targetSnapshot - The target snapshot to re-render. The payload from index.ts is assigned to targetSnapshot
3125
*/
3226
return async function timeJump(targetSnapshot: Tree): Promise<void> {
27+
mode.jumping = true;
3328
console.log('timeJump - START JUMPING');
3429
// Reset mode.navigating
3530
delete mode.navigating;

0 commit comments

Comments
 (0)