@@ -100,6 +100,37 @@ describe('dangerfile-utils', () => {
100100 const multipleParens = getFlavorConfig ( 'feat(scope1)(scope2)' ) ;
101101 assert . strictEqual ( multipleParens . changelog , 'Features' ) ; // Should strip at first (
102102 } ) ;
103+
104+ it ( 'should handle non-conventional action words' , ( ) => {
105+ // Feature-related words
106+ const addConfig = getFlavorConfig ( 'add' ) ;
107+ assert . strictEqual ( addConfig . changelog , 'Features' ) ;
108+ assert . strictEqual ( addConfig . isFeature , true ) ;
109+
110+ const implementConfig = getFlavorConfig ( 'implement' ) ;
111+ assert . strictEqual ( implementConfig . changelog , 'Features' ) ;
112+ assert . strictEqual ( implementConfig . isFeature , true ) ;
113+
114+ // Fix-related words
115+ const resolveConfig = getFlavorConfig ( 'resolve' ) ;
116+ assert . strictEqual ( resolveConfig . changelog , 'Fixes' ) ;
117+
118+ const correctConfig = getFlavorConfig ( 'correct' ) ;
119+ assert . strictEqual ( correctConfig . changelog , 'Fixes' ) ;
120+
121+ // Internal change words
122+ const updateConfig = getFlavorConfig ( 'update' ) ;
123+ assert . strictEqual ( updateConfig . changelog , undefined ) ;
124+
125+ const bumpConfig = getFlavorConfig ( 'bump' ) ;
126+ assert . strictEqual ( bumpConfig . changelog , undefined ) ;
127+
128+ const cleanupConfig = getFlavorConfig ( 'cleanup' ) ;
129+ assert . strictEqual ( cleanupConfig . changelog , undefined ) ;
130+
131+ const formatConfig = getFlavorConfig ( 'format' ) ;
132+ assert . strictEqual ( formatConfig . changelog , undefined ) ;
133+ } ) ;
103134 } ) ;
104135
105136 describe ( 'extractPRFlavor' , ( ) => {
@@ -131,14 +162,20 @@ describe('dangerfile-utils', () => {
131162 } ) ;
132163
133164 it ( 'should return empty string if no flavor found' , ( ) => {
134- const flavor1 = extractPRFlavor ( 'Simple title' , null ) ;
165+ // Empty or whitespace-only strings
166+ const flavor1 = extractPRFlavor ( '' , null ) ;
135167 assert . strictEqual ( flavor1 , '' ) ;
136168
137- const flavor2 = extractPRFlavor ( null , 'simple-branch' ) ;
169+ const flavor2 = extractPRFlavor ( ' ' , null ) ;
138170 assert . strictEqual ( flavor2 , '' ) ;
139171
140- const flavor3 = extractPRFlavor ( null , null ) ;
172+ // No branch with slash
173+ const flavor3 = extractPRFlavor ( null , 'simple-branch' ) ;
141174 assert . strictEqual ( flavor3 , '' ) ;
175+
176+ // All null/undefined
177+ const flavor4 = extractPRFlavor ( null , null ) ;
178+ assert . strictEqual ( flavor4 , '' ) ;
142179 } ) ;
143180
144181 it ( 'should handle edge cases' , ( ) => {
@@ -172,6 +209,32 @@ describe('dangerfile-utils', () => {
172209 const flavor5 = extractPRFlavor ( 'valid: title' , 42 ) ;
173210 assert . strictEqual ( flavor5 , 'valid' ) ;
174211 } ) ;
212+
213+ it ( 'should extract first word from non-conventional PR titles' , ( ) => {
214+ // Non-conventional titles starting with action words
215+ const flavor1 = extractPRFlavor ( 'Fix memory leak in authentication' , null ) ;
216+ assert . strictEqual ( flavor1 , 'fix' ) ;
217+
218+ const flavor2 = extractPRFlavor ( 'Add support for new API endpoint' , null ) ;
219+ assert . strictEqual ( flavor2 , 'add' ) ;
220+
221+ const flavor3 = extractPRFlavor ( 'Update dependencies to latest versions' , null ) ;
222+ assert . strictEqual ( flavor3 , 'update' ) ;
223+
224+ const flavor4 = extractPRFlavor ( 'Remove deprecated configuration options' , null ) ;
225+ assert . strictEqual ( flavor4 , 'remove' ) ;
226+
227+ const flavor5 = extractPRFlavor ( 'Bump version to 2.0.0' , null ) ;
228+ assert . strictEqual ( flavor5 , 'bump' ) ;
229+
230+ // Should still prefer conventional format over first word
231+ const flavor6 = extractPRFlavor ( 'chore: Update dependencies to latest versions' , null ) ;
232+ assert . strictEqual ( flavor6 , 'chore' ) ;
233+
234+ // Handle extra whitespace
235+ const flavor7 = extractPRFlavor ( ' Fix memory leak ' , null ) ;
236+ assert . strictEqual ( flavor7 , 'fix' ) ;
237+ } ) ;
175238 } ) ;
176239
177240
0 commit comments