import { d } from "@alloy-js/core/testing"; import { expect, it } from "vitest"; import { JSDocParam } from "../src/components/JSDocParam.jsx"; import { JSDoc } from "../src/index.js"; it("name only", () => { const template = ( ); expect(template).toRenderTo( d` /** * @param somebody */ `, ); }); it("name and type", () => { const template = ( ); expect(template).toRenderTo( d` /** * @param {string} somebody */ `, ); }); it("name, type and description", () => { const template = ( Somebody's name. ); expect(template).toRenderTo( d` /** * @param {string} somebody Somebody's name. */ `, ); }); it("name, type and description with hyphen", () => { const template = ( Somebody's name. ); expect(template).toRenderTo( d` /** * @param {string} somebody - Somebody's name. */ `, ); }); it("name, type, description, hyphen and optional", () => { const template = ( Somebody's name. ); expect(template).toRenderTo( d` /** * @param {string} [somebody] - Somebody's name. */ `, ); }); it("name, type, description, hyphen and optional with default value", () => { const template = ( Somebody's name. ); expect(template).toRenderTo( d` /** * @param {string} [somebody=John Doe] - Somebody's name. */ `, ); }); it("name, type, description, hyphen and optional with default value with a very lon description", () => { const template = ( Somebody's name. This can be any string representing a person, whether it's a first name, full name, nickname, or even a codename (e.g., "Agent X"). It's used primarily for display purposes, logging, or greeting messages and is not required to be unique or validated unless specified by the caller. Somebody's name. This can be any string representing a person, whether it's a first name, full name, nickname, or even a codename (e.g., "Agent X"). It's used primarily for display purposes, logging, or greeting messages and is not required to be unique or validated unless specified by the caller. ); expect(template).toRenderTo( d` /** * @param {string} [somebody=John Doe] - Somebody's name. This can be any string * representing a person, whether it's a first name, full name, nickname, or * even a codename (e.g., "Agent X"). It's used primarily for display * purposes, logging, or greeting messages and is not required to be unique or * validated unless specified by the caller. * * @param {string} somebody2 - Somebody's name. This can be any string * representing a person, whether it's a first name, full name, nickname, or * even a codename (e.g., "Agent X"). It's used primarily for display * purposes, logging, or greeting messages and is not required to be unique or * validated unless specified by the caller. */ `, { printWidth: 80 }, ); }); it("name, type, description, hyphen and optional with default value with a description containing a linebreak", () => { const template = ( Somebody's name. This is one line This is another line ); expect(template).toRenderTo( d` /** * @param {string} [somebody=John Doe] - Somebody's name. This is one line * This is another line */ `, { printWidth: 80 }, ); });