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.

803 B
Raw Blame
import { act, cleanup, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vite-plus/test";
import { DueDateText } from "./due-date-text";

vi.mock("react-i18next", async (original) => ({
  ...(await original<object>()),
  useTranslation: () => ({ t: (key: string) => key }),
}));

afterEach(() => {
  cleanup();
  vi.useRealTimers();
});

it("updates relative due-date text at midnight with unchanged props", () => {
  vi.useFakeTimers();
  vi.setSystemTime(new Date(2030, 0, 1, 23, 59, 59));
  render(<DueDateText dueDate={new Date(2030, 0, 2, 12).toISOString()} />);
  expect(screen.getByText("workspace:myWork.due.tomorrow")).toBeVisible();
  act(() => vi.advanceTimersByTime(1000));
  expect(screen.getByText("workspace:myWork.due.today")).toBeVisible();
});