Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

841 B
Raw Blame
import { act, renderHook } from "@testing-library/react";
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
import { useCompletionLinger } from "./use-completion-linger";

beforeEach(() => vi.useFakeTimers());
afterEach(() => vi.useRealTimers());

it("lingers only after an active run finishes", () => {
  const { result, rerender } = renderHook(
    ({ active }) => useCompletionLinger(active, 700),
    { initialProps: { active: true } },
  );
  expect(result.current).toBe(false);

  rerender({ active: false });
  expect(result.current).toBe(true);

  act(() => vi.advanceTimersByTime(700));
  expect(result.current).toBe(false);
});

it("does not linger for a run that was already finished", () => {
  const { result } = renderHook(() => useCompletionLinger(false, 700));
  expect(result.current).toBe(false);
});