diff --git a/docs/yarn.lock b/docs/yarn.lock index 532d7abd7ff..f8894d90519 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -133,10 +133,10 @@ version "0.0.0" uid "" -"@mantine/store@7.1.1": - version "7.1.1" - resolved "https://registry.yarnpkg.com/@mantine/store/-/store-7.1.1.tgz#859071535c97fc54862ffe946f58d95cb0455777" - integrity sha512-gCF59GbcRdAOqhrjWQczCAL3Hg+gMaiuATkXFCgbjkwIYXy22zlFAnSKckKHxWuRu7d51dJkPrGelnc7HtZQzA== +"@mantine/store@7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@mantine/store/-/store-7.1.2.tgz#bbdf9b7e9f1f97978100868c1a705e4bc0ac7e74" + integrity sha512-Lf3FLymM0q92BuRC4tZxTxrb9EjVa+J8fqEV147u/Q3aUSNmkhJCqN2MXPbTHIBJ2PsbLtDhy/2edNyIK1KhKQ== "@mantine/store@link:../src/mantine-store": version "0.0.0" diff --git a/src/mantine-hooks/src/use-timeout/use-timeout.test.ts b/src/mantine-hooks/src/use-timeout/use-timeout.test.ts index cae2140d8af..0be06daeec6 100644 --- a/src/mantine-hooks/src/use-timeout/use-timeout.test.ts +++ b/src/mantine-hooks/src/use-timeout/use-timeout.test.ts @@ -70,6 +70,20 @@ describe('@mantine/hooks/use-timeout', () => { expect(setTimeout).toHaveBeenCalled(); }); + it('callback should be called when rerender is triggered before timeout', () => { + const { timeout, advanceTimerToNextTick } = setupTimer(); + const { rerender, result } = renderHook(() => useTimeout(callback, timeout)); + + result.current.start(); + + rerender(); + + advanceTimerToNextTick(); + + expect(callback).toHaveBeenCalled(); + expect(setTimeout).toHaveBeenCalled(); + }); + it('timeout is cleared on calling clear', () => { const { timeout, advanceTimerToNextTick } = setupTimer(10); const hook = renderHook(() => useTimeout(callback, timeout, { autoInvoke: false }));