import { describe, expect, test } from "vitest";

import { MAX_CHAT_IMAGE_BYTES, validateChatImage } from "./attachments";

describe("chat image attachments", () => {
  test("accepts supported image payloads within the upload limit", () => {
    expect(validateChatImage({ size: 1024, type: "image/png" })).toEqual({
      accepted: true,
    });
  });

  test("rejects non-images and oversized images before transport", () => {
    expect(validateChatImage({ size: 1024, type: "text/plain" }).accepted).toBe(
      false
    );
    expect(
      validateChatImage({
        size: MAX_CHAT_IMAGE_BYTES + 1,
        type: "image/jpeg",
      }).accepted
    ).toBe(false);
  });
});
