Skip to content

Commit f47a514

Browse files
committed
fix: cover empty versions
1 parent 51651ef commit f47a514

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/lib/commands/publish.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,3 +1186,37 @@ t.test('ALLOWS publish when not published yet', async t => {
11861186
}).reply(200, {})
11871187
await npm.exec('publish', [])
11881188
})
1189+
1190+
t.test('ALLOWS publish when not published yet (no versions)', async t => {
1191+
const version = '100.0.0'
1192+
1193+
const { npm } = await loadMockNpm(t, {
1194+
config: {
1195+
loglevel: 'silent',
1196+
[`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token',
1197+
},
1198+
prefixDir: {
1199+
'package.json': JSON.stringify({
1200+
...pkgJson,
1201+
version,
1202+
publishConfig: { registry: alternateRegistry },
1203+
}, null, 2),
1204+
},
1205+
mocks: {
1206+
...mockNpmRegistryFetch({
1207+
[`/${pkg}`]: { versions: {} },
1208+
}).mocks,
1209+
},
1210+
})
1211+
const registry = new MockRegistry({
1212+
tap: t,
1213+
registry: alternateRegistry,
1214+
authorization: 'test-other-token',
1215+
})
1216+
registry.nock.put(`/${pkg}`, body => {
1217+
return t.match(body, putPackagePayload({
1218+
pkg, alternateRegistry, version,
1219+
}))
1220+
}).reply(200, {})
1221+
await npm.exec('publish', [])
1222+
})

0 commit comments

Comments
 (0)