import { describe, it, expect } from "vitest";
import { isFeedbackErrorCode } from "./feedbackService";

describe("isFeedbackErrorCode", () => {
  it("recognizes the four stable error codes", () => {
    expect(isFeedbackErrorCode("invalid")).toBe(true);
    expect(isFeedbackErrorCode("rate_limit")).toBe(true);
    expect(isFeedbackErrorCode("server_error")).toBe(true);
    expect(isFeedbackErrorCode("network_error")).toBe(true);
  });

  it("rejects unknown strings and non-strings", () => {
    expect(isFeedbackErrorCode("boom")).toBe(false);
    expect(isFeedbackErrorCode("")).toBe(false);
    expect(isFeedbackErrorCode(404)).toBe(false);
    expect(isFeedbackErrorCode(null)).toBe(false);
    expect(isFeedbackErrorCode(undefined)).toBe(false);
    expect(isFeedbackErrorCode({ error: "rate_limit" })).toBe(false);
  });
});
