Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 25, 2019
1 parent 972ef63 commit bf6d6eb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"bail": "^1.0.0",
"execa": "^1.0.0",
"execa": "^2.0.0",
"figures": "^3.0.0",
"nyc": "^14.0.0",
"prettier": "^1.0.0",
Expand All @@ -41,7 +41,7 @@
"strip-ansi": "^5.0.0",
"tape": "^4.0.0",
"touch": "^3.0.0",
"unified": "^7.0.0",
"unified": "^8.0.0",
"vfile-reporter-json": "^2.0.0",
"xo": "^0.24.0",
"xtend": "^4.0.0"
Expand Down
63 changes: 44 additions & 19 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ test('unified-args', function(t) {
'missing.txt',
' 1:1 error No such file or directory',
'',
figures.cross + ' 1 error',
''
figures.cross + ' 1 error'
].join('\n')

st.plan(1)

execa(bin, ['missing.txt']).then(st.fail, onfail)

function onfail(res) {
st.deepEqual([res.code, strip(res.stderr)], [1, expected], 'should fail')
st.deepEqual(
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
}
})

Expand Down Expand Up @@ -120,38 +123,56 @@ test('unified-args', function(t) {
})

t.test('should fail on a bad short flag', function(st) {
var expected = read(join(cwd, 'SHORT_FLAG'), 'utf8').replace(/\r/g, '')
var expected = read(join(cwd, 'SHORT_FLAG'), 'utf8')
.replace(/\r/g, '')
.trim()

st.plan(1)

execa(bin, ['-n']).then(st.fail, onfail)

function onfail(res) {
st.deepEqual([res.code, strip(res.stderr)], [1, expected], 'should fail')
st.deepEqual(
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
}
})

t.test('should fail on a bad grouped short flag', function(st) {
var expected = read(join(cwd, 'SHORT_FLAG'), 'utf8').replace(/\r/g, '')
var expected = read(join(cwd, 'SHORT_FLAG'), 'utf8')
.replace(/\r/g, '')
.trim()

st.plan(1)

execa(bin, ['-on']).then(st.fail, onfail)

function onfail(res) {
st.deepEqual([res.code, strip(res.stderr)], [1, expected], 'should fail')
st.deepEqual(
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
}
})

t.test('should fail on a bad long flag', function(st) {
var expected = read(join(cwd, 'LONG_FLAG'), 'utf8').replace(/\r/g, '')
var expected = read(join(cwd, 'LONG_FLAG'), 'utf8')
.replace(/\r/g, '')
.trim()

st.plan(1)

execa(bin, ['--no']).then(st.fail, onfail)

function onfail(res) {
st.deepEqual([res.code, strip(res.stderr)], [1, expected], 'should fail')
st.deepEqual(
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
}
})

Expand Down Expand Up @@ -232,7 +253,7 @@ test('unified-args', function(t) {

t.test('should fail on `' + flag + '` without value', function(st) {
var expected =
'Error: Missing value: -e --ext <extensions> specify extensions\n'
'Error: Missing value: -e --ext <extensions> specify extensions'

st.plan(1)

Expand Down Expand Up @@ -268,7 +289,7 @@ test('unified-args', function(t) {
settingsFlags.forEach(function(flag) {
t.test('should catch syntax errors in `' + flag + '`', function(st) {
var expected =
"Error: Cannot parse `foo:bar` as JSON: JSON5: invalid character 'b' at 1:6\n"
"Error: Cannot parse `foo:bar` as JSON: JSON5: invalid character 'b' at 1:6"

st.plan(1)

Expand All @@ -277,7 +298,7 @@ test('unified-args', function(t) {

function onfail(res) {
st.deepEqual(
[res.code, strip(res.stderr)],
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
Expand Down Expand Up @@ -340,7 +361,7 @@ test('unified-args', function(t) {

t.test('should catch syntax errors in `' + flag + '`', function(st) {
var expected =
"Error: Cannot parse `foo:bar` as JSON: JSON5: invalid character 'b' at 1:6\n"
"Error: Cannot parse `foo:bar` as JSON: JSON5: invalid character 'b' at 1:6"

st.plan(1)

Expand All @@ -349,7 +370,7 @@ test('unified-args', function(t) {

function onfail(res) {
st.deepEqual(
[res.code, strip(res.stderr)],
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
Expand Down Expand Up @@ -428,8 +449,8 @@ test('unified-args', function(t) {

function onfail(res) {
st.deepEqual(
[res.code, res.stderr],
[1, 'Error: Missing value: --report <reporter> specify reporter\n'],
[res.exitCode, res.stderr],
[1, 'Error: Missing value: --report <reporter> specify reporter'],
'should fail'
)
}
Expand Down Expand Up @@ -558,20 +579,24 @@ test('unified-args', function(t) {
.slice(0, 2)
.join('\n')

st.deepEqual([res.code, actual], [1, expected], 'should fail')
st.deepEqual([res.exitCode, actual], [1, expected], 'should fail')
}
})

t.test('should report uncaught exceptions', function(st) {
var bin = join(fixtures, 'uncaught-errors', 'cli.js')
var expected = 'one.txt: no issues found\nfoo\n'
var expected = 'one.txt: no issues found\nfoo'

st.plan(1)

execa(bin, ['.', '-u', './plugin']).then(st.fail, onfail)

function onfail(res) {
st.deepEqual([res.code, strip(res.stderr)], [1, expected], 'should fail')
st.deepEqual(
[res.exitCode, strip(res.stderr)],
[1, expected],
'should fail'
)
}
})

Expand Down

0 comments on commit bf6d6eb

Please sign in to comment.