node-clinic/test/cli-clean-full.test.js
Rafael Gonzaga 87e8a215dc
chore: add ci support node 16 (#292)
* chore: bump tap version

* chore: add v16 to test matrix

* chore: update coverage settings to latest tap version

* chore: use taprc

* chore: support v17

* chore: updade coverage settings
2021-10-28 09:41:21 -03:00

43 lines
1.0 KiB
JavaScript

'use strict'
const fs = require('fs')
const path = require('path')
const test = require('tap').test
const cli = require('./cli.js')
test('clinic clean', function (t) {
// collect data
cli({}, [
'clinic', 'doctor', '--no-open',
'--', 'node', '-e', 'setTimeout(() => {}, 500)'
], function (err, stdout, stderr, tempdir) {
t.error(err)
fs.readdir(tempdir, function (err, files) {
t.error(err)
t.same(files, ['.clinic'])
fs.writeFileSync(path.join(tempdir, 'some-other-file'), 'sup')
cli({ cwd: tempdir }, ['clinic', 'clean'], function (err) {
t.error(err)
fs.readdir(tempdir, function (err, files) {
t.error(err)
t.same(files, ['some-other-file'])
t.end()
})
})
})
})
})
test('clinic clean on bad dir', function (t) {
cli({ relayStderr: false }, [
'clinic', 'clean', '--path', 'path/does/not/exist'
], function (err, stdout, stderr) {
t.ok(err)
t.ok(/ENOENT/.test(stderr))
t.end()
})
})