11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ciconst mockNpm = require('../../fixtures/mock-npm') 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cit.cleanSnapshot = s => s.trim().replace(/\n+/g, '\n') 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst mockTeam = async (t, { libnpmteam, ...opts } = {}) => { 71cb0ef41Sopenharmony_ci const mock = await mockNpm(t, { 81cb0ef41Sopenharmony_ci ...opts, 91cb0ef41Sopenharmony_ci command: 'team', 101cb0ef41Sopenharmony_ci mocks: { 111cb0ef41Sopenharmony_ci // XXX: this should be refactored to use the mock registry 121cb0ef41Sopenharmony_ci libnpmteam: libnpmteam || { 131cb0ef41Sopenharmony_ci async add () {}, 141cb0ef41Sopenharmony_ci async create () {}, 151cb0ef41Sopenharmony_ci async destroy () {}, 161cb0ef41Sopenharmony_ci async lsTeams () {}, 171cb0ef41Sopenharmony_ci async lsUsers () {}, 181cb0ef41Sopenharmony_ci async rm () {}, 191cb0ef41Sopenharmony_ci }, 201cb0ef41Sopenharmony_ci }, 211cb0ef41Sopenharmony_ci }) 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci return { 241cb0ef41Sopenharmony_ci ...mock, 251cb0ef41Sopenharmony_ci result: () => mock.joinedOutput(), 261cb0ef41Sopenharmony_ci } 271cb0ef41Sopenharmony_ci} 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_cit.test('no args', async t => { 301cb0ef41Sopenharmony_ci const { team } = await mockTeam(t) 311cb0ef41Sopenharmony_ci await t.rejects( 321cb0ef41Sopenharmony_ci team.exec([]), 331cb0ef41Sopenharmony_ci 'usage instructions', 341cb0ef41Sopenharmony_ci 'should throw usage instructions' 351cb0ef41Sopenharmony_ci ) 361cb0ef41Sopenharmony_ci}) 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cit.test('team add <scope:team> <user>', async t => { 391cb0ef41Sopenharmony_ci t.test('default output', async t => { 401cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t) 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci await team.exec(['add', '@npmcli:developers', 'foo']) 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output success result for add user') 451cb0ef41Sopenharmony_ci }) 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 481cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 491cb0ef41Sopenharmony_ci config: { parseable: true }, 501cb0ef41Sopenharmony_ci }) 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci await team.exec(['add', '@npmcli:developers', 'foo']) 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci t.matchSnapshot( 551cb0ef41Sopenharmony_ci result(), 561cb0ef41Sopenharmony_ci 'should output success result for parseable add user' 571cb0ef41Sopenharmony_ci ) 581cb0ef41Sopenharmony_ci }) 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci t.test('--json', async t => { 611cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 621cb0ef41Sopenharmony_ci config: { json: true }, 631cb0ef41Sopenharmony_ci }) 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci await team.exec(['add', '@npmcli:developers', 'foo']) 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci t.same( 681cb0ef41Sopenharmony_ci JSON.parse(result()), 691cb0ef41Sopenharmony_ci { 701cb0ef41Sopenharmony_ci added: true, 711cb0ef41Sopenharmony_ci team: 'npmcli:developers', 721cb0ef41Sopenharmony_ci user: 'foo', 731cb0ef41Sopenharmony_ci }, 741cb0ef41Sopenharmony_ci 'should output success result for add user json' 751cb0ef41Sopenharmony_ci ) 761cb0ef41Sopenharmony_ci }) 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci t.test('--silent', async t => { 791cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 801cb0ef41Sopenharmony_ci config: { silent: true }, 811cb0ef41Sopenharmony_ci }) 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci await team.exec(['add', '@npmcli:developers', 'foo']) 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci t.same(result(), '', 'should not output success if silent') 861cb0ef41Sopenharmony_ci }) 871cb0ef41Sopenharmony_ci}) 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_cit.test('team create <scope:team>', async t => { 901cb0ef41Sopenharmony_ci t.test('default output', async t => { 911cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t) 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci await team.exec(['create', '@npmcli:newteam']) 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output success result for create team') 961cb0ef41Sopenharmony_ci }) 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 991cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1001cb0ef41Sopenharmony_ci config: { parseable: true }, 1011cb0ef41Sopenharmony_ci }) 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci await team.exec(['create', '@npmcli:newteam']) 1041cb0ef41Sopenharmony_ci 1051cb0ef41Sopenharmony_ci t.matchSnapshot( 1061cb0ef41Sopenharmony_ci result(), 1071cb0ef41Sopenharmony_ci 'should output parseable success result for create team' 1081cb0ef41Sopenharmony_ci ) 1091cb0ef41Sopenharmony_ci }) 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci t.test('--json', async t => { 1121cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1131cb0ef41Sopenharmony_ci config: { json: true }, 1141cb0ef41Sopenharmony_ci }) 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci await team.exec(['create', '@npmcli:newteam']) 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci t.same( 1191cb0ef41Sopenharmony_ci JSON.parse(result()), 1201cb0ef41Sopenharmony_ci { 1211cb0ef41Sopenharmony_ci created: true, 1221cb0ef41Sopenharmony_ci team: 'npmcli:newteam', 1231cb0ef41Sopenharmony_ci }, 1241cb0ef41Sopenharmony_ci 'should output success result for create team' 1251cb0ef41Sopenharmony_ci ) 1261cb0ef41Sopenharmony_ci }) 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci t.test('--silent', async t => { 1291cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1301cb0ef41Sopenharmony_ci config: { silent: true }, 1311cb0ef41Sopenharmony_ci }) 1321cb0ef41Sopenharmony_ci 1331cb0ef41Sopenharmony_ci await team.exec(['create', '@npmcli:newteam']) 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci t.same(result(), '', 'should not output create success if silent') 1361cb0ef41Sopenharmony_ci }) 1371cb0ef41Sopenharmony_ci}) 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_cit.test('team destroy <scope:team>', async t => { 1401cb0ef41Sopenharmony_ci t.test('default output', async t => { 1411cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t) 1421cb0ef41Sopenharmony_ci await team.exec(['destroy', '@npmcli:newteam']) 1431cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output success result for destroy team') 1441cb0ef41Sopenharmony_ci }) 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 1471cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1481cb0ef41Sopenharmony_ci config: { parseable: true }, 1491cb0ef41Sopenharmony_ci }) 1501cb0ef41Sopenharmony_ci await team.exec(['destroy', '@npmcli:newteam']) 1511cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output parseable result for destroy team') 1521cb0ef41Sopenharmony_ci }) 1531cb0ef41Sopenharmony_ci 1541cb0ef41Sopenharmony_ci t.test('--json', async t => { 1551cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1561cb0ef41Sopenharmony_ci config: { json: true }, 1571cb0ef41Sopenharmony_ci }) 1581cb0ef41Sopenharmony_ci await team.exec(['destroy', '@npmcli:newteam']) 1591cb0ef41Sopenharmony_ci t.same( 1601cb0ef41Sopenharmony_ci JSON.parse(result()), 1611cb0ef41Sopenharmony_ci { 1621cb0ef41Sopenharmony_ci deleted: true, 1631cb0ef41Sopenharmony_ci team: 'npmcli:newteam', 1641cb0ef41Sopenharmony_ci }, 1651cb0ef41Sopenharmony_ci 'should output parseable result for destroy team' 1661cb0ef41Sopenharmony_ci ) 1671cb0ef41Sopenharmony_ci }) 1681cb0ef41Sopenharmony_ci 1691cb0ef41Sopenharmony_ci t.test('--silent', async t => { 1701cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 1711cb0ef41Sopenharmony_ci config: { silent: true }, 1721cb0ef41Sopenharmony_ci }) 1731cb0ef41Sopenharmony_ci await team.exec(['destroy', '@npmcli:newteam']) 1741cb0ef41Sopenharmony_ci t.same(result(), '', 'should not output destroy if silent') 1751cb0ef41Sopenharmony_ci }) 1761cb0ef41Sopenharmony_ci}) 1771cb0ef41Sopenharmony_ci 1781cb0ef41Sopenharmony_cit.test('team ls <scope>', async t => { 1791cb0ef41Sopenharmony_ci const teams = { 1801cb0ef41Sopenharmony_ci async lsTeams () { 1811cb0ef41Sopenharmony_ci return [ 1821cb0ef41Sopenharmony_ci 'npmcli:developers', 1831cb0ef41Sopenharmony_ci 'npmcli:designers', 1841cb0ef41Sopenharmony_ci 'npmcli:product', 1851cb0ef41Sopenharmony_ci ] 1861cb0ef41Sopenharmony_ci }, 1871cb0ef41Sopenharmony_ci } 1881cb0ef41Sopenharmony_ci 1891cb0ef41Sopenharmony_ci const noTeam = { 1901cb0ef41Sopenharmony_ci async lsTeams () { 1911cb0ef41Sopenharmony_ci return [] 1921cb0ef41Sopenharmony_ci }, 1931cb0ef41Sopenharmony_ci } 1941cb0ef41Sopenharmony_ci 1951cb0ef41Sopenharmony_ci const singleTeam = { 1961cb0ef41Sopenharmony_ci async lsTeams () { 1971cb0ef41Sopenharmony_ci return ['npmcli:developers'] 1981cb0ef41Sopenharmony_ci }, 1991cb0ef41Sopenharmony_ci } 2001cb0ef41Sopenharmony_ci 2011cb0ef41Sopenharmony_ci t.test('default output', async t => { 2021cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2031cb0ef41Sopenharmony_ci libnpmteam: teams, 2041cb0ef41Sopenharmony_ci }) 2051cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2061cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list teams for a given scope') 2071cb0ef41Sopenharmony_ci }) 2081cb0ef41Sopenharmony_ci 2091cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 2101cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2111cb0ef41Sopenharmony_ci libnpmteam: teams, 2121cb0ef41Sopenharmony_ci config: { parseable: true }, 2131cb0ef41Sopenharmony_ci }) 2141cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2151cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list teams for a parseable scope') 2161cb0ef41Sopenharmony_ci }) 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_ci t.test('--json', async t => { 2191cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2201cb0ef41Sopenharmony_ci libnpmteam: teams, 2211cb0ef41Sopenharmony_ci config: { json: true }, 2221cb0ef41Sopenharmony_ci }) 2231cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2241cb0ef41Sopenharmony_ci t.same( 2251cb0ef41Sopenharmony_ci JSON.parse(result()), 2261cb0ef41Sopenharmony_ci [ 2271cb0ef41Sopenharmony_ci 'npmcli:designers', 2281cb0ef41Sopenharmony_ci 'npmcli:developers', 2291cb0ef41Sopenharmony_ci 'npmcli:product', 2301cb0ef41Sopenharmony_ci ], 2311cb0ef41Sopenharmony_ci 'should json list teams for a scope json' 2321cb0ef41Sopenharmony_ci ) 2331cb0ef41Sopenharmony_ci }) 2341cb0ef41Sopenharmony_ci 2351cb0ef41Sopenharmony_ci t.test('--silent', async t => { 2361cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2371cb0ef41Sopenharmony_ci libnpmteam: teams, 2381cb0ef41Sopenharmony_ci config: { silent: true }, 2391cb0ef41Sopenharmony_ci }) 2401cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2411cb0ef41Sopenharmony_ci t.same(result(), '', 'should not list teams if silent') 2421cb0ef41Sopenharmony_ci }) 2431cb0ef41Sopenharmony_ci 2441cb0ef41Sopenharmony_ci t.test('no teams', async t => { 2451cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2461cb0ef41Sopenharmony_ci libnpmteam: noTeam, 2471cb0ef41Sopenharmony_ci }) 2481cb0ef41Sopenharmony_ci 2491cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2501cb0ef41Sopenharmony_ci 2511cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list no teams for a given scope') 2521cb0ef41Sopenharmony_ci }) 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_ci t.test('single team', async t => { 2551cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2561cb0ef41Sopenharmony_ci libnpmteam: singleTeam, 2571cb0ef41Sopenharmony_ci }) 2581cb0ef41Sopenharmony_ci 2591cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli']) 2601cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list single team for a given scope') 2611cb0ef41Sopenharmony_ci }) 2621cb0ef41Sopenharmony_ci}) 2631cb0ef41Sopenharmony_ci 2641cb0ef41Sopenharmony_cit.test('team ls <scope:team>', async t => { 2651cb0ef41Sopenharmony_ci const users = { 2661cb0ef41Sopenharmony_ci async lsUsers () { 2671cb0ef41Sopenharmony_ci return ['nlf', 'ruyadorno', 'darcyclarke', 'isaacs'] 2681cb0ef41Sopenharmony_ci }, 2691cb0ef41Sopenharmony_ci } 2701cb0ef41Sopenharmony_ci 2711cb0ef41Sopenharmony_ci const singleUser = { 2721cb0ef41Sopenharmony_ci async lsUsers () { 2731cb0ef41Sopenharmony_ci return ['foo'] 2741cb0ef41Sopenharmony_ci }, 2751cb0ef41Sopenharmony_ci } 2761cb0ef41Sopenharmony_ci 2771cb0ef41Sopenharmony_ci const noUsers = { 2781cb0ef41Sopenharmony_ci async lsUsers () { 2791cb0ef41Sopenharmony_ci return [] 2801cb0ef41Sopenharmony_ci }, 2811cb0ef41Sopenharmony_ci } 2821cb0ef41Sopenharmony_ci 2831cb0ef41Sopenharmony_ci t.test('default output', async t => { 2841cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2851cb0ef41Sopenharmony_ci libnpmteam: users, 2861cb0ef41Sopenharmony_ci }) 2871cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 2881cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list users for a given scope:team') 2891cb0ef41Sopenharmony_ci }) 2901cb0ef41Sopenharmony_ci 2911cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 2921cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 2931cb0ef41Sopenharmony_ci libnpmteam: users, 2941cb0ef41Sopenharmony_ci config: { parseable: true }, 2951cb0ef41Sopenharmony_ci }) 2961cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 2971cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list users for a parseable scope:team') 2981cb0ef41Sopenharmony_ci }) 2991cb0ef41Sopenharmony_ci 3001cb0ef41Sopenharmony_ci t.test('--json', async t => { 3011cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3021cb0ef41Sopenharmony_ci libnpmteam: users, 3031cb0ef41Sopenharmony_ci config: { json: true }, 3041cb0ef41Sopenharmony_ci }) 3051cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 3061cb0ef41Sopenharmony_ci t.same( 3071cb0ef41Sopenharmony_ci JSON.parse(result()), 3081cb0ef41Sopenharmony_ci [ 3091cb0ef41Sopenharmony_ci 'darcyclarke', 3101cb0ef41Sopenharmony_ci 'isaacs', 3111cb0ef41Sopenharmony_ci 'nlf', 3121cb0ef41Sopenharmony_ci 'ruyadorno', 3131cb0ef41Sopenharmony_ci ], 3141cb0ef41Sopenharmony_ci 'should list users for a scope:team json' 3151cb0ef41Sopenharmony_ci ) 3161cb0ef41Sopenharmony_ci }) 3171cb0ef41Sopenharmony_ci 3181cb0ef41Sopenharmony_ci t.test('--silent', async t => { 3191cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3201cb0ef41Sopenharmony_ci libnpmteam: users, 3211cb0ef41Sopenharmony_ci config: { silent: true }, 3221cb0ef41Sopenharmony_ci }) 3231cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 3241cb0ef41Sopenharmony_ci t.same(result(), '', 'should not output users if silent') 3251cb0ef41Sopenharmony_ci }) 3261cb0ef41Sopenharmony_ci 3271cb0ef41Sopenharmony_ci t.test('no users', async t => { 3281cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3291cb0ef41Sopenharmony_ci libnpmteam: noUsers, 3301cb0ef41Sopenharmony_ci }) 3311cb0ef41Sopenharmony_ci 3321cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 3331cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list no users for a given scope') 3341cb0ef41Sopenharmony_ci }) 3351cb0ef41Sopenharmony_ci 3361cb0ef41Sopenharmony_ci t.test('single user', async t => { 3371cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3381cb0ef41Sopenharmony_ci libnpmteam: singleUser, 3391cb0ef41Sopenharmony_ci }) 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ci await team.exec(['ls', '@npmcli:developers']) 3421cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should list single user for a given scope') 3431cb0ef41Sopenharmony_ci }) 3441cb0ef41Sopenharmony_ci}) 3451cb0ef41Sopenharmony_ci 3461cb0ef41Sopenharmony_cit.test('team rm <scope:team> <user>', async t => { 3471cb0ef41Sopenharmony_ci t.test('default output', async t => { 3481cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t) 3491cb0ef41Sopenharmony_ci await team.exec(['rm', '@npmcli:newteam', 'foo']) 3501cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output success result for remove user') 3511cb0ef41Sopenharmony_ci }) 3521cb0ef41Sopenharmony_ci 3531cb0ef41Sopenharmony_ci t.test('--parseable', async t => { 3541cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3551cb0ef41Sopenharmony_ci config: { parseable: true }, 3561cb0ef41Sopenharmony_ci }) 3571cb0ef41Sopenharmony_ci await team.exec(['rm', '@npmcli:newteam', 'foo']) 3581cb0ef41Sopenharmony_ci t.matchSnapshot(result(), 'should output parseable result for remove user') 3591cb0ef41Sopenharmony_ci }) 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_ci t.test('--json', async t => { 3621cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3631cb0ef41Sopenharmony_ci config: { json: true }, 3641cb0ef41Sopenharmony_ci }) 3651cb0ef41Sopenharmony_ci await team.exec(['rm', '@npmcli:newteam', 'foo']) 3661cb0ef41Sopenharmony_ci t.same( 3671cb0ef41Sopenharmony_ci JSON.parse(result()), 3681cb0ef41Sopenharmony_ci { 3691cb0ef41Sopenharmony_ci removed: true, 3701cb0ef41Sopenharmony_ci team: 'npmcli:newteam', 3711cb0ef41Sopenharmony_ci user: 'foo', 3721cb0ef41Sopenharmony_ci }, 3731cb0ef41Sopenharmony_ci 'should output json result for remove user' 3741cb0ef41Sopenharmony_ci ) 3751cb0ef41Sopenharmony_ci }) 3761cb0ef41Sopenharmony_ci 3771cb0ef41Sopenharmony_ci t.test('--silent', async t => { 3781cb0ef41Sopenharmony_ci const { team, result } = await mockTeam(t, { 3791cb0ef41Sopenharmony_ci config: { silent: true }, 3801cb0ef41Sopenharmony_ci }) 3811cb0ef41Sopenharmony_ci await team.exec(['rm', '@npmcli:newteam', 'foo']) 3821cb0ef41Sopenharmony_ci t.same(result(), '', 'should not output rm result if silent') 3831cb0ef41Sopenharmony_ci }) 3841cb0ef41Sopenharmony_ci}) 3851cb0ef41Sopenharmony_ci 3861cb0ef41Sopenharmony_cit.test('completion', async t => { 3871cb0ef41Sopenharmony_ci const { team } = await mockTeam(t) 3881cb0ef41Sopenharmony_ci 3891cb0ef41Sopenharmony_ci t.test('npm team autocomplete', async t => { 3901cb0ef41Sopenharmony_ci const res = await team.completion({ 3911cb0ef41Sopenharmony_ci conf: { 3921cb0ef41Sopenharmony_ci argv: { 3931cb0ef41Sopenharmony_ci remain: ['npm', 'team'], 3941cb0ef41Sopenharmony_ci }, 3951cb0ef41Sopenharmony_ci }, 3961cb0ef41Sopenharmony_ci }) 3971cb0ef41Sopenharmony_ci t.strictSame( 3981cb0ef41Sopenharmony_ci res, 3991cb0ef41Sopenharmony_ci ['create', 'destroy', 'add', 'rm', 'ls'], 4001cb0ef41Sopenharmony_ci 'should auto complete with subcommands' 4011cb0ef41Sopenharmony_ci ) 4021cb0ef41Sopenharmony_ci t.end() 4031cb0ef41Sopenharmony_ci }) 4041cb0ef41Sopenharmony_ci 4051cb0ef41Sopenharmony_ci t.test('npm team <subcommand> autocomplete', async t => { 4061cb0ef41Sopenharmony_ci for (const subcmd of ['create', 'destroy', 'add', 'rm', 'ls']) { 4071cb0ef41Sopenharmony_ci const res = await team.completion({ 4081cb0ef41Sopenharmony_ci conf: { 4091cb0ef41Sopenharmony_ci argv: { 4101cb0ef41Sopenharmony_ci remain: ['npm', 'team', subcmd], 4111cb0ef41Sopenharmony_ci }, 4121cb0ef41Sopenharmony_ci }, 4131cb0ef41Sopenharmony_ci }) 4141cb0ef41Sopenharmony_ci t.strictSame( 4151cb0ef41Sopenharmony_ci res, 4161cb0ef41Sopenharmony_ci [], 4171cb0ef41Sopenharmony_ci `should not autocomplete ${subcmd} subcommand` 4181cb0ef41Sopenharmony_ci ) 4191cb0ef41Sopenharmony_ci } 4201cb0ef41Sopenharmony_ci }) 4211cb0ef41Sopenharmony_ci 4221cb0ef41Sopenharmony_ci t.test('npm team unknown subcommand autocomplete', async t => { 4231cb0ef41Sopenharmony_ci t.rejects( 4241cb0ef41Sopenharmony_ci team.completion({ conf: { argv: { remain: ['npm', 'team', 'missing-subcommand'] } } }), 4251cb0ef41Sopenharmony_ci { message: 'missing-subcommand not recognized' }, 'should throw a a not recognized error' 4261cb0ef41Sopenharmony_ci ) 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci t.end() 4291cb0ef41Sopenharmony_ci }) 4301cb0ef41Sopenharmony_ci 4311cb0ef41Sopenharmony_ci t.end() 4321cb0ef41Sopenharmony_ci}) 433