fix: add missing import and update tests for branch template feature (#799)

* fix: add missing import and update tests for branch template feature

- Add missing `import { $ } from 'bun'` in branch.ts
- Add missing `labels` property to pull-request-target.test.ts fixture
- Update branch-template tests to expect 5-word descriptions

* address review feedback: update comment and add truncation test
This commit is contained in:
Ashwin Bhat
2026-01-08 07:07:54 +05:30
committed by GitHub
parent c247cb152d
commit 1b8ee3b941
4 changed files with 25 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ describe("branch template utilities", () => {
"Fix login bug with OAuth",
);
expect(result).toBe("feature/fix-login-bug/123");
expect(result).toBe("feature/fix-login-bug-with-oauth/123");
});
it("should handle template with multiple variables including description", () => {
@@ -172,7 +172,9 @@ describe("branch template utilities", () => {
"User authentication fails completely",
);
expect(result).toBe("dev/bug/user-authentication-fails-issue_456");
expect(result).toBe(
"dev/bug/user-authentication-fails-completely-issue_456",
);
});
it("should handle description with special characters in template", () => {
@@ -187,7 +189,20 @@ describe("branch template utilities", () => {
"Add: User Registration & Email Validation",
);
expect(result).toBe("fix/add-user-registration-789");
expect(result).toBe("fix/add-user-registration-email-789");
});
it("should truncate descriptions to exactly 5 words", () => {
const result = generateBranchName(
"{{prefix}}{{description}}/{{entityNumber}}",
"feature/",
"issue",
999,
undefined,
undefined,
"This is a very long title with many more than five words in it",
);
expect(result).toBe("feature/this-is-a-very-long/999");
});
it("should handle empty description in template", () => {

View File

@@ -87,6 +87,7 @@ describe("pull_request_target event support", () => {
},
comments: { nodes: [] },
reviews: { nodes: [] },
labels: { nodes: [] },
},
comments: [],
changedFiles: [],