import { describe, it, expect } from "vitest";
import { ListOpenTasksRequestSchema, ClaimTaskRequestSchema, TaskDifficulty } from "../src";

describe("Contracts Zod Validation", () => {
  it("should validate a correct ListOpenTasks payload", () => {
    const payload = {
      skills: ["React", "TypeScript"],
      difficulty: TaskDifficulty.COMPONENT,
      limit: 10,
    };
    const result = ListOpenTasksRequestSchema.safeParse(payload);
    expect(result.success).toBe(true);
  });

  it("should reject invalid ListOpenTasks payload", () => {
    const payload = {
      // limit is a string instead of number
      limit: "10",
    };
    const result = ListOpenTasksRequestSchema.safeParse(payload);
    expect(result.success).toBe(false);
  });

  it("should validate a correct ClaimTask payload", () => {
    const payload = {
      task_id: "550e8400-e29b-41d4-a716-446655440000",
      developer_wallet: "0x1234567890123456789012345678901234567890",
    };
    const result = ClaimTaskRequestSchema.safeParse(payload);
    if (!result.success) {
      console.error(result.error);
    }
    expect(result.success).toBe(true);
  });

  it("should reject invalid ClaimTask payload", () => {
    const payload = {
      task_id: "not-a-uuid",
    };
    const result = ClaimTaskRequestSchema.safeParse(payload);
    expect(result.success).toBe(false);
  });
});
