From 5f6cf52c3380f92668eacf382fe658963d7178b9 Mon Sep 17 00:00:00 2001 From: Thijs Daniels Date: Fri, 15 Sep 2023 13:24:14 +0200 Subject: [PATCH] test(react-essentials): add useUpdateLoop test case --- packages/react-essentials/hooks/useUpdateLoop.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/react-essentials/hooks/useUpdateLoop.test.ts b/packages/react-essentials/hooks/useUpdateLoop.test.ts index f2623f90..8ffd973e 100644 --- a/packages/react-essentials/hooks/useUpdateLoop.test.ts +++ b/packages/react-essentials/hooks/useUpdateLoop.test.ts @@ -81,6 +81,17 @@ describe("useUpdateLoop", () => { fps: 50, }), ); + + vi.advanceTimersByTime(2000); + + expect(onUpdate).toHaveBeenLastCalledWith( + expect.objectContaining({ + index: 149, + time: 3000, + deltaTime: 20, + fps: 50, + }), + ); }); it("should not call the onUpdate callback when the loop is paused", () => {