import React from "react";
import { render, screen } from "@sproutsocial/seeds-react-testing-library";
import { Progress } from "../";
describe("Progress", () => {
it("should render with the progressbar role", () => {
render();
expect(screen.getByRole("progressbar")).toBeInTheDocument();
});
it("should set aria-valuenow to the value", () => {
render();
expect(screen.getByRole("progressbar")).toHaveAttribute(
"aria-valuenow",
"33"
);
});
it("should set aria-valuemax to the max", () => {
render();
expect(screen.getByRole("progressbar")).toHaveAttribute(
"aria-valuemax",
"200"
);
});
it("should apply the correct transform for the indicator", () => {
const { container } = render(
);
const indicator = container.querySelector(".Progress > div");
expect(indicator).toHaveStyle("transform: translateX(-25%)");
});
it("should clamp percentage to 100 when value exceeds max", () => {
const { container } = render(
);
const indicator = container.querySelector(".Progress > div");
expect(indicator).toHaveStyle("transform: translateX(-0%)");
});
it("should handle 0 max gracefully", () => {
render();
const progressbar = screen.getByRole("progressbar");
expect(progressbar).toBeInTheDocument();
});
it("should apply custom indicator styles", () => {
const { container } = render(
);
const indicator = container.querySelector(".Progress > div");
expect(indicator).toHaveStyle("background: linear-gradient(red, blue)");
});
it("should use custom getValueLabel", () => {
render(