import { getBlendedColorForRating } from "@/utils/ratingToColor";
import { describe, expect, it } from "vitest";

describe("getBlendedColorForRating", () => {
  // Normal cases
  it("should return red for rating 1", () => {
    expect(getBlendedColorForRating(1)).toBe("rgb(221, 103, 81)");
  });

  it("should return yellow for rating 2", () => {
    expect(getBlendedColorForRating(2)).toBe("rgb(250, 200, 82)");
  });

  it("should return light green for rating 3", () => {
    expect(getBlendedColorForRating(3)).toBe("rgb(120, 222, 163)");
  });

  it("should return dark green for rating 4", () => {
    expect(getBlendedColorForRating(4)).toBe("rgb(91, 183, 130)");
  });

  // Edge cases
  it("should blend red and yellow for a rating between 1 and 2", () => {
    expect(getBlendedColorForRating(1.5)).toBe("rgb(235, 151, 81)");
  });

  it("should blend yellow and light green for a rating between 2 and 3", () => {
    expect(getBlendedColorForRating(2.5)).toBe("rgb(185, 211, 122)");
  });

  it("should blend light green and dark green for a rating between 3 and 4", () => {
    expect(getBlendedColorForRating(3.5)).toBe("rgb(105, 202, 146)");
  });

  // Ratings beyond the scale
  it("should return dark green for ratings above 4", () => {
    expect(getBlendedColorForRating(4.5)).toBe("rgb(91, 183, 130)");
  });

  it("should return grey for ratings below 1", () => {
    expect(getBlendedColorForRating(0.5)).toBe("rgb(237, 242, 246)");
  });
});
