Skip to content

Commit 42f998a

Browse files
ruyadornoisaacs
authored andcommittedDec 17, 2019
Added missing ci tests
PR-URL: #15 Credit: @ruyadorno Close: #15 Reviewed-by: @isaacs
1 parent 280ad2f commit 42f998a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
 

‎test/config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const config = require('../config.js')
4+
const npmlog = require('npmlog')
5+
const { test } = require('tap')
6+
7+
npmlog.level = process.env.LOGLEVEL || 'silent'
8+
9+
test('isFromCI config option', t => {
10+
const CI = process.env.CI
11+
process.env.CI = false
12+
t.teardown(t => {
13+
process.env.CI = CI
14+
})
15+
const OPTS = config({
16+
log: npmlog,
17+
timeout: 0,
18+
registry: 'https://mock.reg/'
19+
})
20+
t.notOk(OPTS.isFromCI, 'should be false if not on a CI env')
21+
t.end()
22+
})

‎test/index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,23 @@ test('log warning header info', t => {
440440
.then(res => t.equal(res.status, 200, 'got successful response'))
441441
})
442442

443+
test('npm-in-ci header with forced CI=false', t => {
444+
const CI = process.env.CI
445+
process.env.CI = false
446+
t.teardown(t => {
447+
process.env.CI = CI
448+
})
449+
tnock(t, OPTS.registry)
450+
.get('/hello')
451+
.reply(200, { hello: 'world' })
452+
return fetch('/hello', OPTS)
453+
.then(res => {
454+
t.equal(res.status, 200, 'got successful response')
455+
})
456+
})
457+
443458
// TODO
444459
// * npm-session
445-
// * npm-in-ci
446460
// * npm-scope
447461
// * referer (opts.refer)
448462
// * user-agent

0 commit comments

Comments
 (0)
Please sign in to comment.