1
1
import chai from 'chai' ;
2
2
import chalk from 'chalk' ;
3
- import { execute } from './test-helpers.js' ;
4
3
import { formatErrors } from 'check-html-links' ;
4
+ import path from 'path' ;
5
+ import { execute } from './test-helpers.js' ;
6
+ import { listFiles } from '../src/listFiles.js' ;
5
7
6
8
const { expect } = chai ;
7
9
8
10
async function executeAndFormat ( inPath ) {
9
- const { errors, cleanup } = await execute ( inPath ) ;
10
- return formatErrors ( cleanup ( errors ) ) ;
11
+ const { errors, cleanup, testDir } = await execute ( inPath ) ;
12
+ const rootDir = path . resolve ( testDir ) ;
13
+ const files = await listFiles ( '**/*.html' , rootDir ) ;
14
+ return formatErrors ( cleanup ( errors ) , { files } ) ;
11
15
}
12
16
13
17
describe ( 'formatErrors' , ( ) => {
@@ -16,23 +20,34 @@ describe('formatErrors', () => {
16
20
chalk . level = 0 ;
17
21
} ) ;
18
22
19
- it ( 'prints a nice summery ' , async ( ) => {
23
+ it ( 'prints a nice summary ' , async ( ) => {
20
24
const result = await executeAndFormat ( 'fixtures/test-case' ) ;
21
25
expect ( result . trim ( ) . split ( '\n' ) ) . to . deep . equal ( [
22
26
'1. missing id="my-teams" in fixtures/test-case/price/index.html' ,
23
27
' from fixtures/test-case/history/index.html:1:9 via href="/price/#my-teams"' ,
24
28
'' ,
29
+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/price/index.html instead?' ,
30
+ '' ,
31
+ '' ,
25
32
'2. missing file fixtures/test-case/about/images/team.png' ,
26
33
' from fixtures/test-case/about/index.html:3:10 via src="./images/team.png"' ,
27
34
'' ,
35
+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/index.html instead?' ,
36
+ '' ,
37
+ '' ,
28
38
'3. missing reference target fixtures/test-case/aboot' ,
29
39
' from fixtures/test-case/about/index.html:6:11 via href="/aboot"' ,
30
40
' from fixtures/test-case/history/index.html:4:11 via href="/aboot"' ,
31
41
' from fixtures/test-case/index.html:4:11 via href="/aboot"' ,
32
42
' ... 2 more references to this target' ,
33
43
'' ,
44
+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/index.html instead?' ,
45
+ '' ,
46
+ '' ,
34
47
'4. missing reference target fixtures/test-case/prce' ,
35
48
' from fixtures/test-case/index.html:1:9 via href="./prce"' ,
49
+ '' ,
50
+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/index.html instead?' ,
36
51
] ) ;
37
52
} ) ;
38
53
} ) ;
0 commit comments