mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import React from "react";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { renderWithSetup } from "test/test-utils";
|
|
|
|
import LastUpdatedText from "./LastUpdatedText";
|
|
|
|
describe("Last updated text", () => {
|
|
it("renders updated text", () => {
|
|
const currentDate = new Date();
|
|
currentDate.setDate(currentDate.getDate() - 2);
|
|
const twoDaysAgo = currentDate.toISOString();
|
|
|
|
render(
|
|
<LastUpdatedText whatToRetrieve="software" lastUpdatedAt={twoDaysAgo} />
|
|
);
|
|
|
|
const text = screen.getByText("Updated 2 days ago");
|
|
|
|
expect(text).toBeInTheDocument();
|
|
});
|
|
it("renders never if missing timestamp", () => {
|
|
render(<LastUpdatedText whatToRetrieve="software" />);
|
|
|
|
const text = screen.getByText("Updated never");
|
|
|
|
expect(text).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders tooltip on hover", async () => {
|
|
const { user } = renderWithSetup(
|
|
<LastUpdatedText whatToRetrieve="software" />
|
|
);
|
|
|
|
await user.hover(screen.getByText("Updated never"));
|
|
|
|
expect(screen.getByText(/to retrieve software/i)).toBeInTheDocument();
|
|
});
|
|
});
|