Skip to content

Commit

Permalink
fix: use 30s default for timeout as per README
Browse files Browse the repository at this point in the history
PR-URL: #20
Credit: @h4l
Close: #20
Reviewed-by: @isaacs
  • Loading branch information
h4l authored and isaacs committed Feb 13, 2020
1 parent fe7b129 commit 69c2977
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ module.exports = figgyPudding({
'scope': {},
'spec': {},
'strict-ssl': {},
'timeout': {},
'timeout': {
default: 30 * 1000
},
'user-agent': {
default: `${
pkg.name
Expand Down
32 changes: 32 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict'

const config = require('../config.js')
const npmlog = require('npmlog')
const { test } = require('tap')

npmlog.level = process.env.LOGLEVEL || 'silent'

test('isFromCI config option', t => {
const CI = process.env.CI
process.env.CI = false
t.teardown(t => {
process.env.CI = CI
})
const OPTS = config({
log: npmlog,
timeout: 0,
registry: 'https://mock.reg/'
})
t.notOk(OPTS.isFromCI, 'should be false if not on a CI env')
t.end()
})

test('default timeout', t => {
const DEFAULT_OPTS = config({})
t.equal(DEFAULT_OPTS.timeout, 30 * 1000, 'default timeout is 30s')
const SPECIFIED_OPTS = config({
timeout: 15 * 1000
})
t.equal(SPECIFIED_OPTS.timeout, 15 * 1000, 'default timeout can be overridden')
t.end()
})

0 comments on commit 69c2977

Please sign in to comment.