@@ -44,7 +44,7 @@ test('without disabledRanges', () => {
4444 report ( v ) ;
4545 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
4646
47- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
47+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
4848 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
4949} ) ;
5050
@@ -68,7 +68,7 @@ test('with irrelevant general disabledRange', () => {
6868 report ( v ) ;
6969 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
7070
71- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
71+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
7272 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
7373} ) ;
7474
@@ -114,7 +114,7 @@ test('with irrelevant rule-specific disabledRange', () => {
114114 report ( v ) ;
115115 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
116116
117- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
117+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
118118 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
119119} ) ;
120120
@@ -276,7 +276,7 @@ test('with custom rule severity', () => {
276276 report ( v ) ;
277277 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
278278
279- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
279+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
280280 expect ( spyArgs [ 1 ] . severity ) . toBe ( 'warning' ) ;
281281 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
282282} ) ;
@@ -396,7 +396,7 @@ test('with message function', () => {
396396 report ( v ) ;
397397 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
398398
399- expect ( spyArgs [ 0 ] ) . toBe ( 'a=str, b=true, c=10, d=/regex/' ) ;
399+ expect ( spyArgs [ 0 ] ) . toBe ( 'a=str, b=true, c=10, d=/regex/ (foo) ' ) ;
400400 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
401401} ) ;
402402
@@ -529,7 +529,7 @@ describe('with fix object', () => {
529529
530530 const spyArgs1 = v . result . warn . mock . calls [ 0 ] ;
531531
532- expect ( spyArgs1 [ 0 ] ) . toBe ( 'bar' ) ;
532+ expect ( spyArgs1 [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
533533 expect ( spyArgs1 [ 1 ] . fix . range ) . toMatchObject ( [ 0 , 3 ] ) ;
534534 expect ( spyArgs1 [ 1 ] . fix . text ) . toBe ( 'bar' ) ;
535535
@@ -543,7 +543,7 @@ describe('with fix object', () => {
543543
544544 const spyArgs2 = v . result . warn . mock . calls [ 1 ] ;
545545
546- expect ( spyArgs2 [ 0 ] ) . toBe ( 'qux' ) ;
546+ expect ( spyArgs2 [ 0 ] ) . toBe ( 'qux (foo) ' ) ;
547547 expect ( spyArgs2 [ 1 ] . fix ) . toBeUndefined ( ) ;
548548 } ) ;
549549
@@ -579,7 +579,7 @@ describe('with fix object', () => {
579579
580580 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
581581
582- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
582+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
583583 expect ( spyArgs [ 1 ] . fix ) . toBeUndefined ( ) ;
584584 } ) ;
585585
@@ -618,7 +618,7 @@ describe('with fix object', () => {
618618
619619 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
620620
621- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
621+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
622622 expect ( spyArgs [ 1 ] . fix ) . toBeUndefined ( ) ;
623623 } ) ;
624624
@@ -652,7 +652,7 @@ describe('with fix object', () => {
652652
653653 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
654654
655- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
655+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
656656 expect ( spyArgs [ 1 ] . fix ) . toBeUndefined ( ) ;
657657 } ) ;
658658
@@ -686,7 +686,7 @@ describe('with fix object', () => {
686686
687687 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
688688
689- expect ( spyArgs [ 0 ] ) . toBe ( 'bar' ) ;
689+ expect ( spyArgs [ 0 ] ) . toBe ( 'bar (foo) ' ) ;
690690 expect ( spyArgs [ 1 ] . fix ) . toBeUndefined ( ) ;
691691 } ) ;
692692} ) ;
@@ -710,7 +710,51 @@ test('with custom message', () => {
710710 report ( v ) ;
711711 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
712712
713- expect ( spyArgs [ 0 ] ) . toBe ( 'A custom message: str, true, 10, /regex/' ) ;
713+ expect ( spyArgs [ 0 ] ) . toBe ( 'A custom message: str, true, 10, /regex/ (foo)' ) ;
714+ expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
715+ } ) ;
716+
717+ test ( 'with custom message (missing rule name)' , ( ) => {
718+ const v = {
719+ ruleName : 'foo' ,
720+ result : {
721+ warn : jest . fn ( ) ,
722+ stylelint : resultStylelint ( {
723+ customMessages : { foo : 'A custom message with appended rule name' } ,
724+ } ) ,
725+ } ,
726+ message : 'bar' ,
727+ node : {
728+ rangeBy : defaultRangeBy ,
729+ } ,
730+ } ;
731+
732+ report ( v ) ;
733+ const spyArgs = v . result . warn . mock . calls [ 0 ] ;
734+
735+ expect ( spyArgs [ 0 ] ) . toBe ( 'A custom message with appended rule name (foo)' ) ;
736+ expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
737+ } ) ;
738+
739+ test ( 'with custom message (appended rule name)' , ( ) => {
740+ const v = {
741+ ruleName : 'foo' ,
742+ result : {
743+ warn : jest . fn ( ) ,
744+ stylelint : resultStylelint ( {
745+ customMessages : { foo : 'A custom message with appended rule name (foo)' } ,
746+ } ) ,
747+ } ,
748+ message : 'bar' ,
749+ node : {
750+ rangeBy : defaultRangeBy ,
751+ } ,
752+ } ;
753+
754+ report ( v ) ;
755+ const spyArgs = v . result . warn . mock . calls [ 0 ] ;
756+
757+ expect ( spyArgs [ 0 ] ) . toBe ( 'A custom message with appended rule name (foo)' ) ;
714758 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
715759} ) ;
716760
@@ -733,7 +777,7 @@ test('with custom message function', () => {
733777 report ( v ) ;
734778 const spyArgs = v . result . warn . mock . calls [ 0 ] ;
735779
736- expect ( spyArgs [ 0 ] ) . toBe ( 'a=str, b=123' ) ;
780+ expect ( spyArgs [ 0 ] ) . toBe ( 'a=str, b=123 (foo) ' ) ;
737781 expect ( spyArgs [ 1 ] . node ) . toBe ( v . node ) ;
738782} ) ;
739783
0 commit comments