1
1
import { describe , it } from 'mocha' ;
2
2
import * as execa from 'execa' ;
3
3
import { assert } from 'chai' ;
4
+ import { LinkResult , LinkState } from '../src/index' ;
4
5
5
6
describe ( 'cli' , ( ) => {
6
7
before ( async ( ) => {
@@ -53,7 +54,6 @@ describe('cli', () => {
53
54
it ( 'should provide CSV if asked nicely' , async ( ) => {
54
55
const res = await execa ( 'npx' , [
55
56
'linkinator' ,
56
- '--markdown' ,
57
57
'--format' ,
58
58
'csv' ,
59
59
'test/fixtures/markdown/README.md' ,
@@ -64,12 +64,12 @@ describe('cli', () => {
64
64
it ( 'should provide JSON if asked nicely' , async ( ) => {
65
65
const res = await execa ( 'npx' , [
66
66
'linkinator' ,
67
- '--markdown' ,
68
67
'--format' ,
69
68
'json' ,
70
69
'test/fixtures/markdown/README.md' ,
71
70
] ) ;
72
- assert . match ( res . stdout , / { / ) ;
71
+ const output = JSON . parse ( res . stdout ) ;
72
+ assert . ok ( output . links ) ;
73
73
} ) ;
74
74
75
75
it ( 'should not show links if --silent' , async ( ) => {
@@ -81,6 +81,21 @@ describe('cli', () => {
81
81
assert . notMatch ( res . stdout , / \[ / ) ;
82
82
} ) ;
83
83
84
+ it ( 'should not show 200 links if verbosity is ERROR with JSON' , async ( ) => {
85
+ const res = await execa ( 'npx' , [
86
+ 'linkinator' ,
87
+ '--verbosity' ,
88
+ 'ERROR' ,
89
+ '--format' ,
90
+ 'JSON' ,
91
+ 'test/fixtures/markdown/README.md' ,
92
+ ] ) ;
93
+ const links = JSON . parse ( res . stdout ) . links as LinkResult [ ] ;
94
+ for ( const link of links ) {
95
+ assert . strictEqual ( link . state , LinkState . BROKEN ) ;
96
+ }
97
+ } ) ;
98
+
84
99
it ( 'should accept a server-root' , async ( ) => {
85
100
const res = await execa ( 'npx' , [
86
101
'linkinator' ,
0 commit comments