Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import DateCell from "./DateCell";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
i18n: { language: "en" },
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("DateCell", () => {
|
||||
it("renders date with default displays", () => {
|
||||
const date = new Date(Date.now() - 60 * 60 * 1000);
|
||||
const { container } = render(<DateCell date={date} />);
|
||||
expect(container.querySelector("div")).not.toBeNull();
|
||||
expect(container.querySelector("div")?.getAttribute("title")).toBeTruthy();
|
||||
expect(container.textContent).toMatch(/ago|vor/i);
|
||||
});
|
||||
|
||||
it("renders date with specific displays", () => {
|
||||
const date = new Date(Date.now() - 60 * 60 * 1000);
|
||||
const { container } = render(<DateCell date={date} displays={["dm", "ago"]} />);
|
||||
expect(container.querySelector("div")).not.toBeNull();
|
||||
expect(container.querySelector("div")?.getAttribute("title")).toBeTruthy();
|
||||
expect(container.textContent).toMatch(/ago|vor/i);
|
||||
expect(container.textContent).not.toContain("ymd");
|
||||
});
|
||||
|
||||
it("renders empty when date is null", () => {
|
||||
const { container } = render(<DateCell date={null} />);
|
||||
expect(container.querySelector("div")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user