%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
const t = require('tap') const pacote = { manifest: async (spec, options) => { return spec === 'nobugs' ? { name: 'nobugs', version: '1.2.3', } : spec === 'bugsurl' ? { name: 'bugsurl', version: '1.2.3', bugs: 'https://bugzilla.localhost/bugsurl', } : spec === 'bugsobj' ? { name: 'bugsobj', version: '1.2.3', bugs: { url: 'https://bugzilla.localhost/bugsobj' }, } : spec === 'bugsobj-nourl' ? { name: 'bugsobj-nourl', version: '1.2.3', bugs: { no: 'url here' }, } : spec === 'repourl' ? { name: 'repourl', version: '1.2.3', repository: 'https://github.com/foo/repourl', } : spec === 'repoobj' ? { name: 'repoobj', version: '1.2.3', repository: { url: 'https://github.com/foo/repoobj' }, } : spec === 'mailtest' ? { name: 'mailtest', version: '3.7.4', bugs: { email: 'hello@example.com' }, } : spec === 'secondmailtest' ? { name: 'secondmailtest', version: '0.1.1', bugs: { email: 'ABC432abc@a.b.example.net' }, } : spec === '.' ? { name: 'thispkg', version: '1.2.3', bugs: 'https://example.com', } : null }, } // keep a tally of which urls got opened let opened = {} const openUrl = async (npm, url, errMsg) => { opened[url] = opened[url] || 0 opened[url]++ } const Bugs = t.mock('../../../lib/commands/bugs.js', { pacote, '../../../lib/utils/open-url.js': openUrl, }) const bugs = new Bugs({ flatOptions: {} }) t.test('usage', (t) => { t.match(bugs.usage, 'bugs', 'usage has command name in it') t.end() }) t.afterEach(() => { opened = {} }) t.test('open bugs urls & emails', t => { const expect = { nobugs: 'https://www.npmjs.com/package/nobugs', 'bugsobj-nourl': 'https://www.npmjs.com/package/bugsobj-nourl', bugsurl: 'https://bugzilla.localhost/bugsurl', bugsobj: 'https://bugzilla.localhost/bugsobj', repourl: 'https://github.com/foo/repourl/issues', repoobj: 'https://github.com/foo/repoobj/issues', mailtest: 'mailto:hello@example.com', secondmailtest: 'mailto:ABC432abc@a.b.example.net', '.': 'https://example.com', } const keys = Object.keys(expect) t.plan(keys.length) keys.forEach(pkg => { t.test(pkg, async t => { await bugs.exec([pkg]) t.equal(opened[expect[pkg]], 1, 'opened expected url', { opened }) }) }) }) t.test('open default package if none specified', async t => { await bugs.exec([]) t.equal(opened['https://example.com'], 1, 'opened expected url', { opened }) })