@@ -438,158 +438,3 @@ test("returns correct position for valid commit (no position needed)", async ()
438438 expect ( result . valid ) . toBe ( true ) ;
439439 expect ( result . errors ) . toHaveLength ( 0 ) ;
440440} ) ;
441-
442- test ( "returns position for subject-full-stop error" , async ( ) => {
443- const result = await lint ( "feat: some message." , {
444- "subject-full-stop" : [ RuleConfigSeverity . Error , "never" , "." ] ,
445- } ) ;
446- expect ( result . valid ) . toBe ( false ) ;
447- expect ( result . errors [ 0 ] . name ) . toBe ( "subject-full-stop" ) ;
448- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
449- expect ( result . errors [ 0 ] . start ?. line ) . toBe ( 1 ) ;
450- expect ( result . errors [ 0 ] . end ) . toBeDefined ( ) ;
451- } ) ;
452-
453- test ( "returns position for header-max-length error" , async ( ) => {
454- const longHeader =
455- "feat: this is a very long header that definitely exceeds the maximum allowed character limit for commit messages" ;
456- const result = await lint ( longHeader , {
457- "header-max-length" : [ RuleConfigSeverity . Error , "always" , 50 ] ,
458- } ) ;
459- expect ( result . valid ) . toBe ( false ) ;
460- expect ( result . errors [ 0 ] . name ) . toBe ( "header-max-length" ) ;
461- expect ( result . errors [ 0 ] . start ) . toEqual ( { line : 1 , column : 1 , offset : 0 } ) ;
462- expect ( result . errors [ 0 ] . end ) . toEqual ( {
463- line : 1 ,
464- column : longHeader . length + 1 ,
465- offset : longHeader . length ,
466- } ) ;
467- } ) ;
468-
469- test ( "returns position for body-max-line-length error" , async ( ) => {
470- const longBodyLine =
471- "this is a body line that is way too long and exceeds the maximum allowed character limit" ;
472- const result = await lint ( `feat: some message\n\n${ longBodyLine } ` , {
473- "body-max-line-length" : [ RuleConfigSeverity . Error , "always" , 50 ] ,
474- } ) ;
475- expect ( result . valid ) . toBe ( false ) ;
476- expect ( result . errors [ 0 ] . name ) . toBe ( "body-max-line-length" ) ;
477- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
478- expect ( result . errors [ 0 ] . start ?. line ) . toBe ( 2 ) ;
479- } ) ;
480-
481- test ( "returns position for header-max-length error" , async ( ) => {
482- const longHeader =
483- "feat: this is a very long header that definitely exceeds the maximum allowed character limit for commit messages" ;
484- const result = await lint ( longHeader , {
485- "header-max-length" : [ RuleConfigSeverity . Error , "always" , 50 ] ,
486- } ) ;
487- expect ( result . valid ) . toBe ( false ) ;
488- expect ( result . errors [ 0 ] . name ) . toBe ( "header-max-length" ) ;
489- expect ( result . errors [ 0 ] . start ) . toEqual ( { line : 1 , column : 1 , offset : 0 } ) ;
490- expect ( result . errors [ 0 ] . end ) . toEqual ( {
491- line : 1 ,
492- column : longHeader . length + 1 ,
493- offset : longHeader . length ,
494- } ) ;
495- } ) ;
496-
497- test ( "returns position for body-max-line-length error" , async ( ) => {
498- const longBodyLine =
499- "this is a body line that is way too long and exceeds the maximum allowed character limit" ;
500- const result = await lint ( `feat: some message\n\n${ longBodyLine } ` , {
501- "body-max-line-length" : [ RuleConfigSeverity . Error , "always" , 50 ] ,
502- } ) ;
503- expect ( result . valid ) . toBe ( false ) ;
504- expect ( result . errors [ 0 ] . name ) . toBe ( "body-max-line-length" ) ;
505- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
506- expect ( result . errors [ 0 ] . start ?. line ) . toBe ( 2 ) ;
507- } ) ;
508-
509- test ( "returns no position for rules without position support" , async ( ) => {
510- const result = await lint ( "somehting #1" , {
511- "references-empty" : [ RuleConfigSeverity . Error , "always" ] ,
512- } ) ;
513- expect ( result . valid ) . toBe ( false ) ;
514- expect ( result . errors [ 0 ] . name ) . toBe ( "references-empty" ) ;
515- expect ( result . errors [ 0 ] . start ) . toBeUndefined ( ) ;
516- expect ( result . errors [ 0 ] . end ) . toBeUndefined ( ) ;
517- } ) ;
518-
519- test ( "returns position when type is provided" , async ( ) => {
520- const result = await lint ( "feat: some message" , {
521- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "bar" ] ] ,
522- } ) ;
523- expect ( result . valid ) . toBe ( false ) ;
524- expect ( result . errors [ 0 ] . name ) . toBe ( "type-enum" ) ;
525- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
526- } ) ;
527-
528- test ( "returns position when scope is provided" , async ( ) => {
529- const result = await lint ( "feat(myscope): some message" , {
530- "scope-enum" : [ RuleConfigSeverity . Error , "always" , [ "other" ] ] ,
531- } ) ;
532- expect ( result . valid ) . toBe ( false ) ;
533- expect ( result . errors [ 0 ] . name ) . toBe ( "scope-enum" ) ;
534- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
535- } ) ;
536-
537- test ( "handles duplicate text in message - uses first occurrence" , async ( ) => {
538- const result = await lint ( "fix: test test" , {
539- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "feat" , "fix" ] ] ,
540- } ) ;
541- expect ( result . valid ) . toBe ( true ) ;
542- expect ( result . errors ) . toHaveLength ( 0 ) ;
543- } ) ;
544-
545- test ( "returns correct position for valid commit (no position needed)" , async ( ) => {
546- const result = await lint ( "feat: add new feature" , {
547- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "feat" , "fix" ] ] ,
548- } ) ;
549- expect ( result . valid ) . toBe ( true ) ;
550- expect ( result . errors ) . toHaveLength ( 0 ) ;
551- } ) ;
552-
553- test ( "returns no position for rules without position support" , async ( ) => {
554- const result = await lint ( "somehting #1" , {
555- "references-empty" : [ RuleConfigSeverity . Error , "always" ] ,
556- } ) ;
557- expect ( result . valid ) . toBe ( false ) ;
558- expect ( result . errors [ 0 ] . name ) . toBe ( "references-empty" ) ;
559- expect ( result . errors [ 0 ] . start ) . toBeUndefined ( ) ;
560- expect ( result . errors [ 0 ] . end ) . toBeUndefined ( ) ;
561- } ) ;
562-
563- test ( "returns position when type is provided" , async ( ) => {
564- const result = await lint ( "feat: some message" , {
565- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "bar" ] ] ,
566- } ) ;
567- expect ( result . valid ) . toBe ( false ) ;
568- expect ( result . errors [ 0 ] . name ) . toBe ( "type-enum" ) ;
569- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
570- } ) ;
571-
572- test ( "returns position when scope is provided" , async ( ) => {
573- const result = await lint ( "feat(myscope): some message" , {
574- "scope-enum" : [ RuleConfigSeverity . Error , "always" , [ "other" ] ] ,
575- } ) ;
576- expect ( result . valid ) . toBe ( false ) ;
577- expect ( result . errors [ 0 ] . name ) . toBe ( "scope-enum" ) ;
578- expect ( result . errors [ 0 ] . start ) . toBeDefined ( ) ;
579- } ) ;
580-
581- test ( "handles duplicate text in message - uses first occurrence" , async ( ) => {
582- const result = await lint ( "fix: test test" , {
583- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "feat" , "fix" ] ] ,
584- } ) ;
585- expect ( result . valid ) . toBe ( true ) ;
586- expect ( result . errors ) . toHaveLength ( 0 ) ;
587- } ) ;
588-
589- test ( "returns correct position for valid commit (no position needed)" , async ( ) => {
590- const result = await lint ( "feat: add new feature" , {
591- "type-enum" : [ RuleConfigSeverity . Error , "always" , [ "feat" , "fix" ] ] ,
592- } ) ;
593- expect ( result . valid ) . toBe ( true ) ;
594- expect ( result . errors ) . toHaveLength ( 0 ) ;
595- } ) ;
0 commit comments