Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-02-25 02:54:50 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-05 00:05:08 +0300
commit4a5dd3a5a200b3f4f7b47168497d8e03dca3a2ca (patch)
treed34a1ea229b719c3cfbdce85899ceaf67b43e7ab /test/lib/restart.js
parentb33c760cea7fe2696d35b5530abc1b455980fef1 (diff)
fix(npm) pass npm context everywhere
Instead of files randomly requiring the npm singleton, we pass it where it needs to go so that tests don't need to do so much require mocking everywhere PR-URL: https://github.com/npm/cli/pull/2772 Credit: @wraithgar Close: #2772 Reviewed-by: @ruyadorno
Diffstat (limited to 'test/lib/restart.js')
-rw-r--r--test/lib/restart.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/lib/restart.js b/test/lib/restart.js
index a19bfd0d4..f29592d9b 100644
--- a/test/lib/restart.js
+++ b/test/lib/restart.js
@@ -1,4 +1,17 @@
const t = require('tap')
-const restart = require('../../lib/restart.js')
-t.isa(restart, Function)
+let runArgs
+const npm = {
+ commands: {
+ 'run-script': (args, cb) => {
+ runArgs = args
+ cb()
+ },
+ },
+}
+const Restart = require('../../lib/restart.js')
+const restart = new Restart(npm)
t.equal(restart.usage, 'npm restart [-- <args>]')
+restart.exec(['foo'], () => {
+ t.match(runArgs, ['restart', 'foo'])
+ t.end()
+})