@@ -14,6 +14,12 @@ test('is a function', () => {
1414 expect ( typeof parse ) . toBe ( 'function' )
1515} )
1616
17+ test ( 'is a function that accepts a string' , ( ) => {
18+ expect ( ( ) => parse ( '' ) ) . not . toThrow ( )
19+ // @ts -ignore
20+ expect ( ( ) => parse ( 1 ) ) . toThrow ( )
21+ } )
22+
1723test ( 'parses a simple patch' , ( ) => {
1824 const patchResult = parse ( data [ 'one-file.patch' ] )
1925 const diffResult = parse ( data [ 'one-file-diff.patch' ] )
@@ -324,6 +330,45 @@ test('parses a add and delete patch', () => {
324330 } )
325331} )
326332
333+ test ( 'parses a add and delete patch with hyphen' , ( ) => {
334+ const result = parse ( data [ 'hyphen.patch' ] )
335+
336+ console . log ( 'result' , JSON . stringify ( parse ( data [ 'hyphen.patch' ] ) , null , 2 ) )
337+
338+ expect ( result ) . toEqual ( {
339+ hash : '89afcd42fb6f2602fbcd03d6e5573b1859347787' ,
340+ authorName : '"Restyled.io"' ,
341+ authorEmail : 'commits@restyled.io' ,
342+ date : 'Fri, 17 Jan 2025 18:09:56 +0000' ,
343+ message : '[PATCH 2/2] Restyled by prettier-yaml' ,
344+ files : [
345+ {
346+ added : false ,
347+ deleted : false ,
348+ beforeName : 'hlint/.hlint.yaml' ,
349+ afterName : 'hlint/.hlint.yaml' ,
350+ modifiedLines : [
351+ {
352+ added : false ,
353+ lineNumber : 27 ,
354+ line : '' ,
355+ } ,
356+ {
357+ added : false ,
358+ lineNumber : 29 ,
359+ line : '- error: {name: ""}' ,
360+ } ,
361+ {
362+ added : true ,
363+ lineNumber : 28 ,
364+ line : '- error: { name: "" }' ,
365+ } ,
366+ ] ,
367+ } ,
368+ ] ,
369+ } )
370+ } )
371+
327372test ( 'parses a complex patch 2' , ( ) => {
328373 parse ( data [ 'complex.patch' ] )
329374} )
0 commit comments