/
zcli.ts
75 lines (67 loc) 路 1.92 KB
/
zcli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {describe, it} from 'mocha';
import * as execa from 'execa';
import {assert} from 'chai';
describe('cli', () => {
before(async () => {
await execa('npm', ['link']);
});
it('should show output for failures', async () => {
const res = await execa('npx', ['linkinator', 'test/fixtures/basic'], {
reject: false,
});
assert.include(res.stderr, 'ERROR: Detected 1 broken links');
});
it('should pass successful markdown scan', async () => {
const res = await execa('npx', [
'linkinator',
'--markdown',
'test/fixtures/markdown/README.md',
]);
assert.include(res.stdout, 'Successfully scanned');
});
it('should show help if no params are provided', async () => {
const res = await execa('npx', ['linkinator'], {
reject: false,
});
assert.include(res.stdout, '$ linkinator LOCATION [ --arguments ]');
});
it('should flag skipped links', async () => {
const res = await execa('npx', [
'linkinator',
'--markdown',
'--skip',
'LICENSE.md',
'test/fixtures/markdown/README.md',
]);
assert.include(res.stdout, '[SKP]');
});
it('should provide CSV if asked nicely', async () => {
const res = await execa('npx', [
'linkinator',
'--markdown',
'--format',
'csv',
'test/fixtures/markdown/README.md',
]);
assert.include(res.stdout, '/README.md,200,OK,');
});
it('should not show links if --silent', async () => {
const res = await execa('npx', [
'linkinator',
'--markdown',
'--silent',
'test/fixtures/markdown/README.md',
]);
assert.strictEqual(res.stdout.indexOf('['), -1);
});
it('should accept a server-root', async () => {
const res = await execa('npx', [
'linkinator',
'--markdown',
'--server-root',
'test/fixtures/markdown',
'README.md',
]);
assert.ok(res.stdout.includes('Successfully scanned'));
});
});