forked from docsifyjs/docsify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (23 loc) · 1001 Bytes
/
index.js
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
'use strict'
const path = require('path')
const execa = require('execa')
const test = require('ava')
let rootCommand = path.join(process.cwd(), 'bin/docsify')
test('shows up help message without any args', async t => {
const {stderr} = await execa(rootCommand, {reject: false})
t.snapshot(stderr)
})
const matchSnapshot = async (t, arg) => {
const args = (typeof arg) === 'object' ? arg : [arg]
const {stdout} = await execa(rootCommand, args)
t.snapshot(stdout)
}
test('shows help with -h flag', matchSnapshot, '-h')
test('shows help with --help flag', matchSnapshot, '--help')
test('shows help with init --help flag', matchSnapshot, ['init', '--help'])
test('shows version information with -v flag', matchSnapshot, '-v')
test('shows version information with --version flag', matchSnapshot, '--version')
test('rejects promise due to error on passing in an unknown command', async t => {
const {stderr} = await execa(rootCommand, ['junkcmd'], {reject: false})
t.snapshot(stderr)
})