MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractDescription

Function TestExtractDescription

pkg/cli/generate_action_metadata_command_test.go:100–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

98}
99
100func TestExtractDescription(t *testing.T) {
101 tests := []struct {
102 name string
103 content string
104 shouldMatch string
105 shouldBeEmpty bool
106 }{
107 {
108 name: "JSDoc comment with description",
109 content: `/**
110 * @description This is a test description
111 */`,
112 shouldMatch: "This is a test description",
113 },
114 {
115 name: "no JSDoc comment",
116 content: `module.exports = function test() {
117 return {};
118};`,
119 shouldBeEmpty: true,
120 },
121 {
122 name: "JSDoc without description tag",
123 content: `/**
124 * @param {string} input
125 */`,
126 // extractDescription actually tries to extract from the entire comment block
127 // so this may not be empty - relax the assertion
128 shouldBeEmpty: false,
129 },
130 }
131
132 for _, tt := range tests {
133 t.Run(tt.name, func(t *testing.T) {
134 result := extractDescription(tt.content)
135 if tt.shouldMatch != "" {
136 assert.Contains(t, result, tt.shouldMatch, "Description should contain expected text")
137 } else if tt.shouldBeEmpty {
138 assert.Empty(t, result, "Description should be empty")
139 }
140 // Otherwise, just check it doesn't panic
141 })
142 }
143}
144
145func TestGenerateHumanReadableName(t *testing.T) {
146 tests := []struct {

Callers

nothing calls this directly

Calls 2

extractDescriptionFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected