Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 8, 2023
1 parent e7ff14d commit 27cd99d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 1 addition & 3 deletions workspaces/libnpmexec/lib/run-script.js
Expand Up @@ -32,9 +32,7 @@ const run = async ({
},
}

if (stdio === 'inherit') {
npmlog.disableProgress()
}
npmlog.disableProgress()

try {
if (script === scriptShell) {
Expand Down
38 changes: 38 additions & 0 deletions workspaces/libnpmexec/test/index.js
Expand Up @@ -14,3 +14,41 @@ t.test('no args', async t => {

await exec()
})

t.test('stdio value', t => {
t.test('stdio default value', t => {
const libexec = t.mock('../lib/index.js', {
'../lib/run-script.js': (opt) => {
t.equal(opt.stdio, 'inherit', 'should use expected stdio value')
},
npmlog: {
disableProgress () {
t.ok('should disable progress')
},
enableProgress () {
t.ok('should enable progress')
},
},
})
libexec({ args: [], runPath: t.testDirName })
})

t.test('stdio custom value', t => {
const libexec = t.mock('../lib/index.js', {
'../lib/run-script.js': (opt) => {
t.equal(opt.stdio, 'pipe', 'should use expected stdio value')
},
npmlog: {
disableProgress () {
t.ok('should disable progress')
},
enableProgress () {
t.fail('should not enable progress')
},
},
})
libexec({ args: [], stdio: 'pipe', runPath: t.testDirName })
})

t.end()
})

0 comments on commit 27cd99d

Please sign in to comment.