import { render, screen } from "@testing-library/react";
import { ReviewSummary } from "../../components/ReviewSummary";
import type { Review } from "../../types";

describe("ReviewSummary", () => {
  it("calculates average from approved reviews", () => {
    const reviews: Review[] = [
      { id: "1", author: "A", rating: 5, text: "", status: "approved", date: "2024-01-01" },
      { id: "2", author: "B", rating: 3, text: "", status: "approved", date: "2024-01-02" },
      { id: "3", author: "C", rating: 1, text: "", status: "pending", date: "2024-01-03" },
    ];

    render(<ReviewSummary reviews={reviews} />);

    expect(screen.getByText("4,0")).toBeInTheDocument();
    expect(screen.getByText(/2 arvostelua/i)).toBeInTheDocument();
  });
});
