Skip to content

Commit 2743170

Browse files
committed
refactor: remove comments from use-simulate-progress test
1 parent 55c119f commit 2743170

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

__test__/use-simulate-progress.test.ts

+7-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { renderHook, act } from '@testing-library/react';
22

33
import { useSimulateProgress } from '../src';
44

5-
// Mock timers
65
jest.useFakeTimers();
76

87
describe('useSimulateProgress', () => {
@@ -12,12 +11,10 @@ describe('useSimulateProgress', () => {
1211
useSimulateProgress(1000, mockCallback),
1312
);
1413

15-
// Progress should initially be 0
1614
expect(result.current[0]).toBe(0);
1715

18-
// Progress should not change before startProgress is called
1916
act(() => {
20-
jest.advanceTimersByTime(500); // Fast-forward 500ms
17+
jest.advanceTimersByTime(500);
2118
});
2219
expect(result.current[0]).toBe(0);
2320
});
@@ -28,31 +25,26 @@ describe('useSimulateProgress', () => {
2825
useSimulateProgress(1000, mockCallback),
2926
);
3027

31-
// Call startProgress to trigger the progress
3228
act(() => {
33-
result.current[1](); // Call startProgress
29+
result.current[1]();
3430
});
3531

36-
// Fast-forward the timer, simulating time passing
3732
act(() => {
38-
jest.advanceTimersByTime(250); // Fast-forward 250ms
33+
jest.advanceTimersByTime(250);
3934
});
4035

41-
// Progress should update to 25%
4236
expect(result.current[0]).toBe(25);
4337

4438
act(() => {
45-
jest.advanceTimersByTime(500); // Fast-forward another 500ms
39+
jest.advanceTimersByTime(500);
4640
});
4741

48-
// Progress should update to 75%
4942
expect(result.current[0]).toBe(75);
5043

5144
act(() => {
52-
jest.advanceTimersByTime(250); // Finish the remaining time
45+
jest.advanceTimersByTime(250);
5346
});
5447

55-
// Progress should be 100%, and callback should be called
5648
expect(result.current[0]).toBe(100);
5749
expect(mockCallback).toHaveBeenCalledTimes(1);
5850
});
@@ -86,31 +78,24 @@ describe('useSimulateProgress', () => {
8678
useSimulateProgress(1000, mockCallback),
8779
);
8880

89-
// Call startProgress to trigger the progress
9081
act(() => {
91-
result.current[1](); // Call startProgress
82+
result.current[1]();
9283
});
9384

94-
// Fast-forward the timer halfway
9585
act(() => {
9686
jest.advanceTimersByTime(500);
9787
});
9888

99-
// Progress should be 50%
10089
expect(result.current[0]).toBe(50);
10190

102-
// Unmount the component
10391
unmount();
10492

105-
// Clear the timer, ensuring no further updates
10693
act(() => {
107-
jest.advanceTimersByTime(500); // Finish the remaining time
94+
jest.advanceTimersByTime(500);
10895
});
10996

110-
// Progress should not update further
11197
expect(result.current[0]).toBe(50);
11298

113-
// Callback should not be called
11499
expect(mockCallback).not.toHaveBeenCalled();
115100
});
116101
});

0 commit comments

Comments
 (0)