diff options
Diffstat (limited to 'test/lib/edit.js')
-rw-r--r-- | test/lib/edit.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/test/lib/edit.js b/test/lib/edit.js index acf03fa43..09908165d 100644 --- a/test/lib/edit.js +++ b/test/lib/edit.js @@ -1,6 +1,5 @@ -const { test } = require('tap') +const t = require('tap') const { resolve } = require('path') -const requireInject = require('require-inject') const { EventEmitter } = require('events') let editorBin = null @@ -39,13 +38,13 @@ const npm = { } const gracefulFs = require('graceful-fs') -const Edit = requireInject('../../lib/edit.js', { +const Edit = t.mock('../../lib/edit.js', { child_process: childProcess, 'graceful-fs': gracefulFs, }) const edit = new Edit(npm) -test('npm edit', t => { +t.test('npm edit', t => { t.teardown(() => { rebuildArgs = null editorBin = null @@ -66,7 +65,7 @@ test('npm edit', t => { }) }) -test('rebuild fails', t => { +t.test('rebuild fails', t => { t.teardown(() => { rebuildFail = null rebuildArgs = null @@ -87,7 +86,7 @@ test('rebuild fails', t => { }) }) -test('npm edit editor has flags', t => { +t.test('npm edit editor has flags', t => { EDITOR = 'code -w' t.teardown(() => { rebuildArgs = null @@ -110,14 +109,14 @@ test('npm edit editor has flags', t => { }) }) -test('npm edit no args', t => { +t.test('npm edit no args', t => { return edit.exec([], (err) => { t.match(err, /npm edit/, 'throws usage error') t.end() }) }) -test('npm edit lstat error propagates', t => { +t.test('npm edit lstat error propagates', t => { const _lstat = gracefulFs.lstat gracefulFs.lstat = (dir, cb) => { return cb(new Error('lstat failed')) @@ -132,7 +131,7 @@ test('npm edit lstat error propagates', t => { }) }) -test('npm edit editor exit code error propagates', t => { +t.test('npm edit editor exit code error propagates', t => { EDITOR_CODE = 137 t.teardown(() => { EDITOR_CODE = 0 |