|
| 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 | + |
1 | 42 | // import timeJumpRequire from '../timeJump';
|
2 | 43 | // import componentActionsRecord from '../masterState';
|
3 | 44 |
|
|
0 commit comments