11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ciconst { load: loadMockNpm } = require('../../fixtures/mock-npm.js') 31cb0ef41Sopenharmony_ciconst MockRegistry = require('@npmcli/mock-registry') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst pkgName = '@npmcli/test-package' 61cb0ef41Sopenharmony_ciconst authToken = 'test-auth-token' 71cb0ef41Sopenharmony_ciconst username = 'test-user' 81cb0ef41Sopenharmony_ciconst auth = { '//registry.npmjs.org/:_authToken': authToken } 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cit.test('no args', async t => { 111cb0ef41Sopenharmony_ci const { npm } = await loadMockNpm(t) 121cb0ef41Sopenharmony_ci await t.rejects( 131cb0ef41Sopenharmony_ci npm.exec('unstar', []), 141cb0ef41Sopenharmony_ci { code: 'EUSAGE' }, 151cb0ef41Sopenharmony_ci 'should throw usage error' 161cb0ef41Sopenharmony_ci ) 171cb0ef41Sopenharmony_ci}) 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cit.test('unstar a package unicode:false', async t => { 201cb0ef41Sopenharmony_ci const { npm, joinedOutput } = await loadMockNpm(t, { 211cb0ef41Sopenharmony_ci config: { unicode: false, ...auth }, 221cb0ef41Sopenharmony_ci }) 231cb0ef41Sopenharmony_ci const registry = new MockRegistry({ 241cb0ef41Sopenharmony_ci tap: t, 251cb0ef41Sopenharmony_ci registry: npm.config.get('registry'), 261cb0ef41Sopenharmony_ci authorization: authToken, 271cb0ef41Sopenharmony_ci }) 281cb0ef41Sopenharmony_ci const manifest = registry.manifest({ name: pkgName, users: { [username]: true } }) 291cb0ef41Sopenharmony_ci await registry.package({ manifest, query: { write: true } }) 301cb0ef41Sopenharmony_ci registry.whoami({ username }) 311cb0ef41Sopenharmony_ci registry.star(manifest, {}) 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci await npm.exec('unstar', [pkgName]) 341cb0ef41Sopenharmony_ci t.equal( 351cb0ef41Sopenharmony_ci joinedOutput(), 361cb0ef41Sopenharmony_ci '( ) @npmcli/test-package', 371cb0ef41Sopenharmony_ci 'should output unstarred package msg' 381cb0ef41Sopenharmony_ci ) 391cb0ef41Sopenharmony_ci}) 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_cit.test('unstar a package unicode:true', async t => { 421cb0ef41Sopenharmony_ci const { npm, joinedOutput } = await loadMockNpm(t, { 431cb0ef41Sopenharmony_ci config: { unicode: true, ...auth }, 441cb0ef41Sopenharmony_ci }) 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci const registry = new MockRegistry({ 471cb0ef41Sopenharmony_ci tap: t, 481cb0ef41Sopenharmony_ci registry: npm.config.get('registry'), 491cb0ef41Sopenharmony_ci authorization: authToken, 501cb0ef41Sopenharmony_ci }) 511cb0ef41Sopenharmony_ci const manifest = registry.manifest({ name: pkgName, users: { [username]: true } }) 521cb0ef41Sopenharmony_ci await registry.package({ manifest, query: { write: true } }) 531cb0ef41Sopenharmony_ci registry.whoami({ username }) 541cb0ef41Sopenharmony_ci registry.star(manifest, {}) 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci await npm.exec('unstar', [pkgName]) 571cb0ef41Sopenharmony_ci t.equal( 581cb0ef41Sopenharmony_ci joinedOutput(), 591cb0ef41Sopenharmony_ci '☆ @npmcli/test-package', 601cb0ef41Sopenharmony_ci 'should output unstarred package msg' 611cb0ef41Sopenharmony_ci ) 621cb0ef41Sopenharmony_ci}) 63