|
1 | 1 | const { describe, it } = require('node:test'); |
2 | 2 | const assert = require('node:assert'); |
3 | | -const { getFlavorConfig, findChangelogInsertionPoint, extractPRFlavor, FLAVOR_CONFIG } = require('./dangerfile-utils.js'); |
| 3 | +const { getFlavorConfig, extractPRFlavor, FLAVOR_CONFIG } = require('./dangerfile-utils.js'); |
4 | 4 |
|
5 | 5 | describe('dangerfile-utils', () => { |
6 | 6 | describe('getFlavorConfig', () => { |
@@ -143,118 +143,6 @@ describe('dangerfile-utils', () => { |
143 | 143 | }); |
144 | 144 | }); |
145 | 145 |
|
146 | | - describe('findChangelogInsertionPoint', () => { |
147 | | - it('should find insertion point in existing section', () => { |
148 | | - const changelog = [ |
149 | | - '# Changelog', |
150 | | - '', |
151 | | - '## Unreleased', |
152 | | - '', |
153 | | - '### Features', |
154 | | - '', |
155 | | - '- Some existing feature ([#123](...))', |
156 | | - '', |
157 | | - '## 1.0.0' |
158 | | - ]; |
159 | | - |
160 | | - const result = findChangelogInsertionPoint(changelog, 'Features'); |
161 | | - assert.strictEqual(result.success, true); |
162 | | - assert.strictEqual(result.lineNumber, 8); // Should insert after existing feature |
163 | | - assert.strictEqual(result.isNewSection, false); |
164 | | - assert.strictEqual(result.sectionHeader, null); |
165 | | - }); |
166 | | - |
167 | | - it('should create new section when section does not exist', () => { |
168 | | - const changelog = [ |
169 | | - '# Changelog', |
170 | | - '', |
171 | | - '## Unreleased', |
172 | | - '', |
173 | | - '### Features', |
174 | | - '', |
175 | | - '- Some existing feature ([#123](...))', |
176 | | - '', |
177 | | - '## 1.0.0' |
178 | | - ]; |
179 | | - |
180 | | - const result = findChangelogInsertionPoint(changelog, 'Security'); |
181 | | - assert.strictEqual(result.success, true); |
182 | | - assert.strictEqual(result.isNewSection, true); |
183 | | - assert.strictEqual(result.sectionHeader, '### Security'); |
184 | | - // Should insert before existing Features section |
185 | | - assert.strictEqual(result.lineNumber, 5); |
186 | | - }); |
187 | | - |
188 | | - it('should handle changelog with no existing sections', () => { |
189 | | - const changelog = [ |
190 | | - '# Changelog', |
191 | | - '', |
192 | | - '## Unreleased', |
193 | | - '', |
194 | | - '## 1.0.0' |
195 | | - ]; |
196 | | - |
197 | | - const result = findChangelogInsertionPoint(changelog, 'Features'); |
198 | | - assert.strictEqual(result.success, true); |
199 | | - assert.strictEqual(result.isNewSection, true); |
200 | | - assert.strictEqual(result.sectionHeader, '### Features'); |
201 | | - // Should insert after Unreleased header |
202 | | - assert.strictEqual(result.lineNumber, 4); |
203 | | - }); |
204 | | - |
205 | | - it('should fail when no Unreleased section exists', () => { |
206 | | - const changelog = [ |
207 | | - '# Changelog', |
208 | | - '', |
209 | | - '## 1.0.0', |
210 | | - '', |
211 | | - '- Initial release' |
212 | | - ]; |
213 | | - |
214 | | - const result = findChangelogInsertionPoint(changelog, 'Features'); |
215 | | - assert.strictEqual(result.success, false); |
216 | | - }); |
217 | | - |
218 | | - it('should handle empty section', () => { |
219 | | - const changelog = [ |
220 | | - '# Changelog', |
221 | | - '', |
222 | | - '## Unreleased', |
223 | | - '', |
224 | | - '### Features', |
225 | | - '', |
226 | | - '### Fixes', |
227 | | - '', |
228 | | - '- Some fix ([#456](...))', |
229 | | - '', |
230 | | - '## 1.0.0' |
231 | | - ]; |
232 | | - |
233 | | - const result = findChangelogInsertionPoint(changelog, 'Features'); |
234 | | - assert.strictEqual(result.success, true); |
235 | | - assert.strictEqual(result.isNewSection, false); |
236 | | - // Should insert in empty Features section |
237 | | - assert.strictEqual(result.lineNumber, 7); |
238 | | - }); |
239 | | - |
240 | | - it('should be case-insensitive for section matching', () => { |
241 | | - const changelog = [ |
242 | | - '# Changelog', |
243 | | - '', |
244 | | - '## unreleased', |
245 | | - '', |
246 | | - '### features', |
247 | | - '', |
248 | | - '- Some existing feature ([#123](...))', |
249 | | - '', |
250 | | - '## 1.0.0' |
251 | | - ]; |
252 | | - |
253 | | - const result = findChangelogInsertionPoint(changelog, 'Features'); |
254 | | - assert.strictEqual(result.success, true); |
255 | | - assert.strictEqual(result.isNewSection, false); |
256 | | - }); |
257 | | - }); |
258 | 146 |
|
259 | 147 | describe('FLAVOR_CONFIG integrity', () => { |
260 | 148 | it('should have unique labels across all configs', () => { |
|
0 commit comments