import { refkey, StatementList } from "@alloy-js/core";
import { expect, it } from "vitest";
import * as ts from "../src/index.js";
import { TestFile } from "./utils.js";
it("renders a function declaration with documentation", () => {
const res = (
);
expect(res).toRenderTo(`
/**
* A function that greets a person
*
* @param {string} name
*/
function greet(name: string): string {}
`);
});
it("With documented parameters", () => {
const res = (
);
expect(res).toRenderTo(`
/**
* Calculates the total price including tax
*
* @param {number} price
* @param {number} [taxRate]
*/
export function calculateTotal(price: number, taxRate?: number): number {}
`);
});
it("renders a function with a reference", () => {
const userRef = refkey();
const res = (
);
expect(res).toRenderTo(`
interface User {
id: number;
name: string;
}
/**
* Creates a new user
*
* @param {User} user - The user object to create
*/
function createUser(user: User): void {}`);
});