Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
test: add basic scoped publish test
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Aug 30, 2018
1 parent 74135c9 commit 6d58f33
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,63 @@ test('basic publish', t => {
})
})
})

test('scoped publish', t => {
const manifest = {
name: '@zkat/libnpmpublish',
version: '1.0.0',
description: 'some stuff'
}
return mockTar({
'package.json': JSON.stringify(manifest),
'index.js': 'console.log("hello world")'
}).then(tarData => {
const shasum = crypto.createHash('sha1').update(tarData).digest('hex')
const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] })
const packument = {
name: '@zkat/libnpmpublish',
description: 'some stuff',
readme: '',
_id: '@zkat/libnpmpublish',
'dist-tags': {
latest: '1.0.0'
},
versions: {
'1.0.0': {
_id: '@zkat/libnpmpublish@1.0.0',
_nodeVersion: process.versions.node,
_npmVersion: '6.9.0',
name: '@zkat/libnpmpublish',
version: '1.0.0',
description: 'some stuff',
dist: {
shasum,
integrity: integrity.toString(),
tarball: `http://mock.reg/@zkat/libnpmpublish/-/@zkat/libnpmpublish-1.0.0.tgz`
}
}
},
_attachments: {
'@zkat/libnpmpublish-1.0.0.tgz': {
'content_type': 'application/octet-stream',
data: tarData.toString('base64'),
length: tarData.length
}
}
}
const srv = tnock(t, REG)
srv.put('/@zkat%2flibnpmpublish', body => {
t.deepEqual(body, packument, 'posted packument matches expectations')
return true
}, {
authorization: 'Bearer deadbeef'
}).reply(201, {})

return publish(manifest, tarData, OPTS.concat({
npmVersion: '6.9.0',
token: 'deadbeef'
})).then(() => {
t.ok(true, 'publish succeeded')
})
})
})

0 comments on commit 6d58f33

Please sign in to comment.