import { describe, it, expect } from "vitest";
import {
generateCommitMessageHandler,
generatePRDescriptionHandler,
updateChangelogHandler,
} from "./communication.js";
describe("Communication Tools", () => {
describe("generateCommitMessageHandler", () => {
it("should generate semantic commit", () => {
const result = generateCommitMessageHandler({
type: "feat",
scope: "auth",
description: "add login",
breaking: true,
});
expect(result.content[0].text).toContain("feat(auth)!: add login");
expect(result.content[0].text).toContain("BREAKING CHANGE");
});
});
describe("generatePRDescriptionHandler", () => {
it("should generate PR description", () => {
const result = generatePRDescriptionHandler({
title: "Add Login",
type: "feature",
summary: "Adds login page",
changes: ["added login.ts", "updated auth"],
});
expect(result.content[0].text).toContain("# Add Login");
expect(result.content[0].text).toContain("✨ New feature");
expect(result.content[0].text).toContain("- added login.ts");
});
});
describe("updateChangelogHandler", () => {
it("should generate changelog entry", () => {
const result = updateChangelogHandler({
version: "1.2.0",
added: ["New feature X"],
fixed: ["Bug Y"],
});
expect(result.content[0].text).toContain("## [1.2.0]");
expect(result.content[0].text).toContain("### Added");
expect(result.content[0].text).toContain("- New feature X");
expect(result.content[0].text).toContain("### Fixed");
});
});
});