11import chai from 'chai' ;
22import chalk from 'chalk' ;
3- import { execute } from './test-helpers.js' ;
43import { formatErrors } from 'check-html-links' ;
4+ import path from 'path' ;
5+ import { execute } from './test-helpers.js' ;
6+ import { listFiles } from '../src/listFiles.js' ;
57
68const { expect } = chai ;
79
810async 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 } ) ;
1115}
1216
1317describe ( 'formatErrors' , ( ) => {
@@ -16,23 +20,34 @@ describe('formatErrors', () => {
1620 chalk . level = 0 ;
1721 } ) ;
1822
19- it ( 'prints a nice summery ' , async ( ) => {
23+ it ( 'prints a nice summary ' , async ( ) => {
2024 const result = await executeAndFormat ( 'fixtures/test-case' ) ;
2125 expect ( result . trim ( ) . split ( '\n' ) ) . to . deep . equal ( [
2226 '1. missing id="my-teams" in fixtures/test-case/price/index.html' ,
2327 ' from fixtures/test-case/history/index.html:1:9 via href="/price/#my-teams"' ,
2428 '' ,
29+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/price/index.html instead?' ,
30+ '' ,
31+ '' ,
2532 '2. missing file fixtures/test-case/about/images/team.png' ,
2633 ' from fixtures/test-case/about/index.html:3:10 via src="./images/team.png"' ,
2734 '' ,
35+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/index.html instead?' ,
36+ '' ,
37+ '' ,
2838 '3. missing reference target fixtures/test-case/aboot' ,
2939 ' from fixtures/test-case/about/index.html:6:11 via href="/aboot"' ,
3040 ' from fixtures/test-case/history/index.html:4:11 via href="/aboot"' ,
3141 ' from fixtures/test-case/index.html:4:11 via href="/aboot"' ,
3242 ' ... 2 more references to this target' ,
3343 '' ,
44+ 'Suggestion: did you mean packages/check-html-links/test-node/fixtures/test-case/index.html instead?' ,
45+ '' ,
46+ '' ,
3447 '4. missing reference target fixtures/test-case/prce' ,
3548 ' 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?' ,
3651 ] ) ;
3752 } ) ;
3853} ) ;
0 commit comments