Skip to content

Commit

Permalink
test: increase CLI test coverage (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Nov 29, 2020
1 parent 524f600 commit f4822f0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .mocharc.json
@@ -1,6 +1,6 @@
{
"check-leaks": true,
"timeout": 10000,
"timeout": 20000,
"throw-deprecation": true,
"enable-source-maps": true
}
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -249,4 +249,4 @@ complex();
## License
[MIT](LICENSE)
[MIT](LICENSE.md)
55 changes: 53 additions & 2 deletions test/zcli.ts
Expand Up @@ -3,11 +3,62 @@ import * as execa from 'execa';
import {assert} from 'chai';

describe('cli', () => {
it('should link and run a basic command', async () => {
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');
}).timeout(60000);
});

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);
});
});

0 comments on commit f4822f0

Please sign in to comment.