@@ -166,6 +166,49 @@ t.test('unpublish <pkg>@version last version', async t => {
166166 )
167167} )
168168
169+ t . test ( 'unpublish <pkg>@version of a packument with no versions' , async t => {
170+ const { npm } = await loadMockNpm ( t , {
171+ config : {
172+ ...auth ,
173+ } ,
174+ } )
175+ const registry = new MockRegistry ( {
176+ tap : t ,
177+ registry : npm . config . get ( 'registry' ) ,
178+ authorization : 'test-auth-token' ,
179+ } )
180+ const manifest = registry . manifest ( { name : pkg } )
181+ delete manifest . versions
182+ await registry . package ( { manifest, query : { write : true } } )
183+
184+ await t . rejects (
185+ npm . exec ( 'unpublish' , [ 'test-package@1.0.0' ] ) ,
186+ / t h e r e g i s t r y r e t u r n e d n o v e r s i o n s f o r t e s t - p a c k a g e /
187+ )
188+ } )
189+
190+ t . test ( 'unpublish <pkg>@version of a packument with no versions with --force' , async t => {
191+ const { npm } = await loadMockNpm ( t , {
192+ config : {
193+ force : true ,
194+ ...auth ,
195+ } ,
196+ } )
197+ const registry = new MockRegistry ( {
198+ tap : t ,
199+ registry : npm . config . get ( 'registry' ) ,
200+ authorization : 'test-auth-token' ,
201+ } )
202+ const manifest = registry . manifest ( { name : pkg } )
203+ manifest . versions = { }
204+ await registry . package ( { manifest, query : { write : true } } )
205+
206+ await t . rejects (
207+ npm . exec ( 'unpublish' , [ 'test-package@1.0.0' ] ) ,
208+ / t h e r e g i s t r y r e t u r n e d n o v e r s i o n s f o r t e s t - p a c k a g e /
209+ )
210+ } )
211+
169212t . test ( 'no version found in package.json no force' , async t => {
170213 const { npm } = await loadMockNpm ( t , {
171214 config : {
0 commit comments