Skip to content
This repository was archived by the owner on Jul 28, 2021. It is now read-only.

Commit e5582ad

Browse files
committed
fix(test): get deprecate tests working again
1 parent e0bdf2d commit e5582ad

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

test/deprecate.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const figgyPudding = require('figgy-pudding')
34
const { log } = require('libnpm')
45
const { test } = require('tap')
56
const tnock = require('./util/tnock.js')
@@ -28,16 +29,19 @@ const cache = {
2829
}
2930

3031
log.level = process.env.LOGLEVEL || 'silent'
31-
const OPTS = {
32+
const OPTS = figgyPudding({
33+
registry: {},
34+
log: {},
35+
loglevel: {}
36+
}, { other () { return true } })({
3237
registry: 'https://mock.reg',
3338
log,
3439
loglevel: log.level
35-
}
40+
})
3641

3742
const deprecate = require('../lib/commands/deprecate.js')
3843

3944
test('tink deprecate an unscoped package', async t => {
40-
// Clone cache and modify it for this test
4145
const deprecated = JSON.parse(JSON.stringify(cache))
4246
deprecated.versions = {
4347
'0.0.0': {},
@@ -46,9 +50,10 @@ test('tink deprecate an unscoped package', async t => {
4650
}
4751

4852
// Clone OPTS and modify it for this test
49-
const opts = JSON.parse(JSON.stringify(OPTS))
50-
opts['pkg@version'] = `${deprecated.name}@0.0.1`
51-
opts.message = deprecated.versions['0.0.1'].deprecated
53+
const opts = OPTS.concat({
54+
'pkg@version': `${deprecated.name}@0.0.1`,
55+
message: deprecated.versions['0.0.1'].deprecated
56+
})
5257

5358
// Setup mock registry server
5459
tnock(t, opts.registry).get('/cond?write=true').reply(200, cache)
@@ -74,9 +79,10 @@ test('tink deprecate a scoped package', async t => {
7479
}
7580

7681
// Clone OPTS and modify it for this test
77-
const opts = JSON.parse(JSON.stringify(OPTS))
78-
opts['pkg@version'] = `${deprecated.name}@0.0.1`
79-
opts.message = deprecated.versions['0.0.1'].deprecated
82+
const opts = OPTS.concat({
83+
'pkg@version': `${deprecated.name}@0.0.1`,
84+
message: deprecated.versions['0.0.1'].deprecated
85+
})
8086

8187
// Setup mock registry server
8288
tnock(t, opts.registry).get('/@scope%2fcond?write=true').reply(200, cacheCopy)
@@ -99,9 +105,10 @@ test('tink deprecate semver range', async t => {
99105
}
100106

101107
// Clone OPTS and modify it for this test
102-
const opts = JSON.parse(JSON.stringify(OPTS))
103-
opts['pkg@version'] = `${deprecated.name}@<0.0.2`
104-
opts.message = deprecated.versions['0.0.1'].deprecated
108+
const opts = OPTS.concat({
109+
'pkg@version': `${deprecated.name}@<0.0.2`,
110+
message: deprecated.versions['0.0.1'].deprecated
111+
})
105112

106113
// Setup mock registry server
107114
tnock(t, opts.registry).get('/cond?write=true').reply(200, cache)
@@ -116,9 +123,10 @@ test('tink deprecate semver range', async t => {
116123

117124
test('tink deprecate bad semver range', async t => {
118125
// Clone OPTS and modify it for this test
119-
const opts = JSON.parse(JSON.stringify(OPTS))
120-
opts['pkg@version'] = `${cache.name}@-9001`
121-
opts.message = 'make it dead'
126+
const opts = OPTS.concat({
127+
'pkg@version': `${cache.name}@-9001`,
128+
message: 'make it dead'
129+
})
122130

123131
// Test that an exception is thrown
124132
t.rejects(deprecate.handler(opts), 'invalid version range: -9001')
@@ -134,9 +142,10 @@ test('tink deprecate a package with no semver range', async t => {
134142
}
135143

136144
// Clone OPTS and modify it for this test
137-
const opts = JSON.parse(JSON.stringify(OPTS))
138-
opts['pkg@version'] = deprecated.name
139-
opts.message = deprecated.versions['0.0.0'].deprecated
145+
const opts = OPTS.concat({
146+
'pkg@version': deprecated.name,
147+
message: deprecated.versions['0.0.0'].deprecated
148+
})
140149

141150
// Setup mock registry server
142151
tnock(t, opts.registry).get('/cond?write=true').reply(200, cache)

0 commit comments

Comments
 (0)