import { describe, expect, test } from "bun:test";
import {
  assertUploadedFiles,
  formatFileSize,
  uploadAccept,
  uploaderAttributes,
} from "../src/index.ts";

describe("uploader helper kit", () => {
  test("formats sizes and builds uploader attributes", () => {
    expect(formatFileSize(1024)).toContain("KB");
    expect(uploadAccept(["image/png", ".jpg"])).toBe("image/png,.jpg");
    expect(uploaderAttributes({ store: "public", multiple: true })["data-uploader"]).toBe("public");
  });

  test("asserts uploaded file count and status", () => {
    const files = [{ name: "a.png", size: 10, type: "image/png", key: "a", url: "/a" }];
    expect(assertUploadedFiles(files, { min: 1, max: 1 })).toEqual(files);
    expect(() => assertUploadedFiles([], { min: 1 })).toThrow();
  });
});
