import { describe, expect, it } from "bun:test";
import { parseId } from "../../src/server/lib/params";

describe("parseId", () => {
	it("returns number for valid positive integers", () => {
		expect(parseId("1")).toBe(1);
		expect(parseId("42")).toBe(42);
		expect(parseId("999")).toBe(999);
	});

	it("returns null for zero", () => {
		expect(parseId("0")).toBeNull();
	});

	it("returns null for negative numbers", () => {
		expect(parseId("-1")).toBeNull();
		expect(parseId("-100")).toBeNull();
	});

	it("returns null for decimals", () => {
		expect(parseId("1.5")).toBeNull();
		expect(parseId("3.14")).toBeNull();
	});

	it("returns null for non-numeric strings", () => {
		expect(parseId("abc")).toBeNull();
		expect(parseId("")).toBeNull();
		expect(parseId("hello")).toBeNull();
		expect(parseId("12abc")).toBeNull();
	});

	it("returns null for special values", () => {
		expect(parseId("NaN")).toBeNull();
		expect(parseId("Infinity")).toBeNull();
		expect(parseId("-Infinity")).toBeNull();
	});
});
