1- const markdownlint = require ( "markdownlint" ) ;
21const altTextRule = require ( "../no-default-alt-text" ) ;
3-
4- const thisRuleName = altTextRule . names [ 1 ] ;
5-
6- const config = {
7- config : {
8- default : false ,
9- [ thisRuleName ] : true ,
10- } ,
11- customRules : [ altTextRule ] ,
12- } ;
13-
14- async function runTest ( strings ) {
15- return await Promise . all (
16- strings . map ( ( variation ) => {
17- const thisTestConfig = {
18- ...config ,
19- strings : [ variation ] ,
20- } ;
21-
22- return new Promise ( ( resolve , reject ) => {
23- markdownlint ( thisTestConfig , ( err , result ) => {
24- if ( err ) reject ( err ) ;
25- resolve ( result [ 0 ] [ 0 ] ) ;
26- } ) ;
27- } ) ;
28- } )
29- ) ;
30- }
2+ const runTest = require ( "./utils/run-test" ) . runTest ;
313
324describe ( "GH001: No Default Alt Text" , ( ) => {
335 describe ( "successes" , ( ) => {
@@ -36,7 +8,7 @@ describe("GH001: No Default Alt Text", () => {
368 "" ,
379 ] ;
3810
39- const results = await runTest ( strings ) ;
11+ const results = await runTest ( strings , altTextRule ) ;
4012
4113 for ( const result of results ) {
4214 expect ( result ) . not . toBeDefined ( ) ;
@@ -47,7 +19,7 @@ describe("GH001: No Default Alt Text", () => {
4719 '<img alt="A helpful description" src="https://user-images.githubusercontent.com/abcdef.png">' ,
4820 ] ;
4921
50- const results = await runTest ( strings ) ;
22+ const results = await runTest ( strings , altTextRule ) ;
5123
5224 for ( const result of results ) {
5325 expect ( result ) . not . toBeDefined ( ) ;
@@ -63,7 +35,7 @@ describe("GH001: No Default Alt Text", () => {
6335 "" ,
6436 ] ;
6537
66- const results = await runTest ( strings ) ;
38+ const results = await runTest ( strings , altTextRule ) ;
6739
6840 const failedRules = results
6941 . map ( ( result ) => result . ruleNames )
@@ -72,7 +44,7 @@ describe("GH001: No Default Alt Text", () => {
7244
7345 expect ( failedRules ) . toHaveLength ( 4 ) ;
7446 for ( const rule of failedRules ) {
75- expect ( rule ) . toBe ( thisRuleName ) ;
47+ expect ( rule ) . toBe ( "no-default-alt-text" ) ;
7648 }
7749 } ) ;
7850
@@ -84,7 +56,7 @@ describe("GH001: No Default Alt Text", () => {
8456 '<img alt="Screenshot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">' ,
8557 ] ;
8658
87- const results = await runTest ( strings ) ;
59+ const results = await runTest ( strings , altTextRule ) ;
8860
8961 const failedRules = results
9062 . map ( ( result ) => result . ruleNames )
@@ -93,7 +65,7 @@ describe("GH001: No Default Alt Text", () => {
9365
9466 expect ( failedRules ) . toHaveLength ( 4 ) ;
9567 for ( const rule of failedRules ) {
96- expect ( rule ) . toBe ( thisRuleName ) ;
68+ expect ( rule ) . toBe ( "no-default-alt-text" ) ;
9769 }
9870 } ) ;
9971
@@ -103,7 +75,7 @@ describe("GH001: No Default Alt Text", () => {
10375 '<img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">' ,
10476 ] ;
10577
106- const results = await runTest ( strings ) ;
78+ const results = await runTest ( strings , altTextRule ) ;
10779
10880 expect ( results [ 0 ] . ruleDescription ) . toMatch (
10981 / I m a g e s s h o u l d n o t u s e t h e M a c O S d e f a u l t s c r e e n s h o t f i l e n a m e a s a l t e r n a t e t e x t /
0 commit comments