(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func 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 | |
| 145 | func TestGenerateHumanReadableName(t *testing.T) { |
| 146 | tests := []struct { |
nothing calls this directly
no test coverage detected