2024-06-26 13:17:43 +00:00
|
|
|
import React from "react";
|
2024-11-25 18:28:58 +00:00
|
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
2024-06-26 13:17:43 +00:00
|
|
|
|
|
|
|
|
import StatusIndicator from "./StatusIndicator";
|
|
|
|
|
|
|
|
|
|
describe("Status indicator", () => {
|
|
|
|
|
it("renders status as capitalized", () => {
|
|
|
|
|
render(<StatusIndicator value="paused" />);
|
|
|
|
|
|
|
|
|
|
expect(screen.getByText("Paused")).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("renders optional tooltip on hover", async () => {
|
|
|
|
|
const TOOLTIP_TEXT = "Online hosts will respond to a live query.";
|
|
|
|
|
render(
|
|
|
|
|
<StatusIndicator value="online" tooltip={{ tooltipText: TOOLTIP_TEXT }} />
|
|
|
|
|
);
|
|
|
|
|
|
2024-11-25 18:28:58 +00:00
|
|
|
await fireEvent.mouseEnter(screen.getByText("Online"));
|
2024-06-26 13:17:43 +00:00
|
|
|
|
|
|
|
|
expect(screen.getByText(TOOLTIP_TEXT)).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|