1
- const markdownlint = require ( "markdownlint" ) ;
2
1
const 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 ;
31
3
32
4
describe ( "GH001: No Default Alt Text" , ( ) => {
33
5
describe ( "successes" , ( ) => {
@@ -36,7 +8,7 @@ describe("GH001: No Default Alt Text", () => {
36
8
"" ,
37
9
] ;
38
10
39
- const results = await runTest ( strings ) ;
11
+ const results = await runTest ( strings , altTextRule ) ;
40
12
41
13
for ( const result of results ) {
42
14
expect ( result ) . not . toBeDefined ( ) ;
@@ -47,7 +19,7 @@ describe("GH001: No Default Alt Text", () => {
47
19
'<img alt="A helpful description" src="https://user-images.githubusercontent.com/abcdef.png">' ,
48
20
] ;
49
21
50
- const results = await runTest ( strings ) ;
22
+ const results = await runTest ( strings , altTextRule ) ;
51
23
52
24
for ( const result of results ) {
53
25
expect ( result ) . not . toBeDefined ( ) ;
@@ -63,7 +35,7 @@ describe("GH001: No Default Alt Text", () => {
63
35
"" ,
64
36
] ;
65
37
66
- const results = await runTest ( strings ) ;
38
+ const results = await runTest ( strings , altTextRule ) ;
67
39
68
40
const failedRules = results
69
41
. map ( ( result ) => result . ruleNames )
@@ -72,7 +44,7 @@ describe("GH001: No Default Alt Text", () => {
72
44
73
45
expect ( failedRules ) . toHaveLength ( 4 ) ;
74
46
for ( const rule of failedRules ) {
75
- expect ( rule ) . toBe ( thisRuleName ) ;
47
+ expect ( rule ) . toBe ( "no-default-alt-text" ) ;
76
48
}
77
49
} ) ;
78
50
@@ -84,7 +56,7 @@ describe("GH001: No Default Alt Text", () => {
84
56
'<img alt="Screenshot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">' ,
85
57
] ;
86
58
87
- const results = await runTest ( strings ) ;
59
+ const results = await runTest ( strings , altTextRule ) ;
88
60
89
61
const failedRules = results
90
62
. map ( ( result ) => result . ruleNames )
@@ -93,7 +65,7 @@ describe("GH001: No Default Alt Text", () => {
93
65
94
66
expect ( failedRules ) . toHaveLength ( 4 ) ;
95
67
for ( const rule of failedRules ) {
96
- expect ( rule ) . toBe ( thisRuleName ) ;
68
+ expect ( rule ) . toBe ( "no-default-alt-text" ) ;
97
69
}
98
70
} ) ;
99
71
@@ -103,7 +75,7 @@ describe("GH001: No Default Alt Text", () => {
103
75
'<img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png">' ,
104
76
] ;
105
77
106
- const results = await runTest ( strings ) ;
78
+ const results = await runTest ( strings , altTextRule ) ;
107
79
108
80
expect ( results [ 0 ] . ruleDescription ) . toMatch (
109
81
/ 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