11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ciconst mockNpm = require('../../fixtures/mock-npm') 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst version = '1.0.0' 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst funding = { 71cb0ef41Sopenharmony_ci type: 'individual', 81cb0ef41Sopenharmony_ci url: 'http://example.com/donate', 91cb0ef41Sopenharmony_ci} 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst maintainerOwnsAllDeps = { 121cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 131cb0ef41Sopenharmony_ci name: 'maintainer-owns-all-deps', 141cb0ef41Sopenharmony_ci version, 151cb0ef41Sopenharmony_ci funding, 161cb0ef41Sopenharmony_ci dependencies: { 171cb0ef41Sopenharmony_ci 'dep-foo': '*', 181cb0ef41Sopenharmony_ci 'dep-bar': '*', 191cb0ef41Sopenharmony_ci }, 201cb0ef41Sopenharmony_ci }), 211cb0ef41Sopenharmony_ci node_modules: { 221cb0ef41Sopenharmony_ci 'dep-foo': { 231cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 241cb0ef41Sopenharmony_ci name: 'dep-foo', 251cb0ef41Sopenharmony_ci version, 261cb0ef41Sopenharmony_ci funding, 271cb0ef41Sopenharmony_ci dependencies: { 281cb0ef41Sopenharmony_ci 'dep-sub-foo': '*', 291cb0ef41Sopenharmony_ci }, 301cb0ef41Sopenharmony_ci }), 311cb0ef41Sopenharmony_ci node_modules: { 321cb0ef41Sopenharmony_ci 'dep-sub-foo': { 331cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 341cb0ef41Sopenharmony_ci name: 'dep-sub-foo', 351cb0ef41Sopenharmony_ci version, 361cb0ef41Sopenharmony_ci funding, 371cb0ef41Sopenharmony_ci }), 381cb0ef41Sopenharmony_ci }, 391cb0ef41Sopenharmony_ci }, 401cb0ef41Sopenharmony_ci }, 411cb0ef41Sopenharmony_ci 'dep-bar': { 421cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 431cb0ef41Sopenharmony_ci name: 'dep-bar', 441cb0ef41Sopenharmony_ci version, 451cb0ef41Sopenharmony_ci funding, 461cb0ef41Sopenharmony_ci }), 471cb0ef41Sopenharmony_ci }, 481cb0ef41Sopenharmony_ci }, 491cb0ef41Sopenharmony_ci} 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciconst nestedNoFundingPackages = { 521cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 531cb0ef41Sopenharmony_ci name: 'nested-no-funding-packages', 541cb0ef41Sopenharmony_ci version, 551cb0ef41Sopenharmony_ci dependencies: { 561cb0ef41Sopenharmony_ci foo: '*', 571cb0ef41Sopenharmony_ci }, 581cb0ef41Sopenharmony_ci devDependencies: { 591cb0ef41Sopenharmony_ci lorem: '*', 601cb0ef41Sopenharmony_ci }, 611cb0ef41Sopenharmony_ci }), 621cb0ef41Sopenharmony_ci node_modules: { 631cb0ef41Sopenharmony_ci foo: { 641cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 651cb0ef41Sopenharmony_ci name: 'foo', 661cb0ef41Sopenharmony_ci version, 671cb0ef41Sopenharmony_ci dependencies: { 681cb0ef41Sopenharmony_ci bar: '*', 691cb0ef41Sopenharmony_ci }, 701cb0ef41Sopenharmony_ci }), 711cb0ef41Sopenharmony_ci node_modules: { 721cb0ef41Sopenharmony_ci bar: { 731cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 741cb0ef41Sopenharmony_ci name: 'bar', 751cb0ef41Sopenharmony_ci version, 761cb0ef41Sopenharmony_ci funding, 771cb0ef41Sopenharmony_ci }), 781cb0ef41Sopenharmony_ci node_modules: { 791cb0ef41Sopenharmony_ci 'sub-bar': { 801cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 811cb0ef41Sopenharmony_ci name: 'sub-bar', 821cb0ef41Sopenharmony_ci version, 831cb0ef41Sopenharmony_ci funding: 'https://example.com/sponsor', 841cb0ef41Sopenharmony_ci }), 851cb0ef41Sopenharmony_ci }, 861cb0ef41Sopenharmony_ci }, 871cb0ef41Sopenharmony_ci }, 881cb0ef41Sopenharmony_ci }, 891cb0ef41Sopenharmony_ci }, 901cb0ef41Sopenharmony_ci lorem: { 911cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 921cb0ef41Sopenharmony_ci name: 'lorem', 931cb0ef41Sopenharmony_ci version, 941cb0ef41Sopenharmony_ci funding: { 951cb0ef41Sopenharmony_ci url: 'https://example.com/lorem', 961cb0ef41Sopenharmony_ci }, 971cb0ef41Sopenharmony_ci }), 981cb0ef41Sopenharmony_ci }, 991cb0ef41Sopenharmony_ci }, 1001cb0ef41Sopenharmony_ci} 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ciconst nestedMultipleFundingPackages = { 1031cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1041cb0ef41Sopenharmony_ci name: 'nested-multiple-funding-packages', 1051cb0ef41Sopenharmony_ci version, 1061cb0ef41Sopenharmony_ci funding: ['https://one.example.com', 'https://two.example.com'], 1071cb0ef41Sopenharmony_ci dependencies: { 1081cb0ef41Sopenharmony_ci foo: '*', 1091cb0ef41Sopenharmony_ci }, 1101cb0ef41Sopenharmony_ci devDependencies: { 1111cb0ef41Sopenharmony_ci bar: '*', 1121cb0ef41Sopenharmony_ci }, 1131cb0ef41Sopenharmony_ci }), 1141cb0ef41Sopenharmony_ci node_modules: { 1151cb0ef41Sopenharmony_ci foo: { 1161cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1171cb0ef41Sopenharmony_ci name: 'foo', 1181cb0ef41Sopenharmony_ci version, 1191cb0ef41Sopenharmony_ci funding: [ 1201cb0ef41Sopenharmony_ci 'http://example.com', 1211cb0ef41Sopenharmony_ci { url: 'http://sponsors.example.com/me' }, 1221cb0ef41Sopenharmony_ci 'http://collective.example.com', 1231cb0ef41Sopenharmony_ci ], 1241cb0ef41Sopenharmony_ci }), 1251cb0ef41Sopenharmony_ci }, 1261cb0ef41Sopenharmony_ci bar: { 1271cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1281cb0ef41Sopenharmony_ci name: 'bar', 1291cb0ef41Sopenharmony_ci version, 1301cb0ef41Sopenharmony_ci funding: ['http://collective.example.com', { url: 'http://sponsors.example.com/you' }], 1311cb0ef41Sopenharmony_ci }), 1321cb0ef41Sopenharmony_ci }, 1331cb0ef41Sopenharmony_ci }, 1341cb0ef41Sopenharmony_ci} 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ciconst conflictingFundingPackages = { 1371cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1381cb0ef41Sopenharmony_ci name: 'conflicting-funding-packages', 1391cb0ef41Sopenharmony_ci version, 1401cb0ef41Sopenharmony_ci dependencies: { 1411cb0ef41Sopenharmony_ci foo: '1.0.0', 1421cb0ef41Sopenharmony_ci }, 1431cb0ef41Sopenharmony_ci devDependencies: { 1441cb0ef41Sopenharmony_ci bar: '1.0.0', 1451cb0ef41Sopenharmony_ci }, 1461cb0ef41Sopenharmony_ci }), 1471cb0ef41Sopenharmony_ci node_modules: { 1481cb0ef41Sopenharmony_ci foo: { 1491cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1501cb0ef41Sopenharmony_ci name: 'foo', 1511cb0ef41Sopenharmony_ci version: '1.0.0', 1521cb0ef41Sopenharmony_ci funding: 'http://example.com/1', 1531cb0ef41Sopenharmony_ci }), 1541cb0ef41Sopenharmony_ci }, 1551cb0ef41Sopenharmony_ci bar: { 1561cb0ef41Sopenharmony_ci node_modules: { 1571cb0ef41Sopenharmony_ci foo: { 1581cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1591cb0ef41Sopenharmony_ci name: 'foo', 1601cb0ef41Sopenharmony_ci version: '2.0.0', 1611cb0ef41Sopenharmony_ci funding: 'http://example.com/2', 1621cb0ef41Sopenharmony_ci }), 1631cb0ef41Sopenharmony_ci }, 1641cb0ef41Sopenharmony_ci }, 1651cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 1661cb0ef41Sopenharmony_ci name: 'bar', 1671cb0ef41Sopenharmony_ci version: '1.0.0', 1681cb0ef41Sopenharmony_ci dependencies: { 1691cb0ef41Sopenharmony_ci foo: '2.0.0', 1701cb0ef41Sopenharmony_ci }, 1711cb0ef41Sopenharmony_ci }), 1721cb0ef41Sopenharmony_ci }, 1731cb0ef41Sopenharmony_ci }, 1741cb0ef41Sopenharmony_ci} 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_ciconst setup = async (t, { openUrl, ...opts } = {}) => { 1771cb0ef41Sopenharmony_ci const openedUrls = [] 1781cb0ef41Sopenharmony_ci 1791cb0ef41Sopenharmony_ci const res = await mockNpm(t, { 1801cb0ef41Sopenharmony_ci ...opts, 1811cb0ef41Sopenharmony_ci mocks: { 1821cb0ef41Sopenharmony_ci '@npmcli/promise-spawn': { open: openUrl || (async url => openedUrls.push(url)) }, 1831cb0ef41Sopenharmony_ci pacote: { 1841cb0ef41Sopenharmony_ci manifest: arg => 1851cb0ef41Sopenharmony_ci arg.name === 'ntl' 1861cb0ef41Sopenharmony_ci ? Promise.resolve({ funding: 'http://example.com/pacote' }) 1871cb0ef41Sopenharmony_ci : Promise.reject(new Error('ERROR')), 1881cb0ef41Sopenharmony_ci }, 1891cb0ef41Sopenharmony_ci ...opts.mocks, 1901cb0ef41Sopenharmony_ci }, 1911cb0ef41Sopenharmony_ci }) 1921cb0ef41Sopenharmony_ci 1931cb0ef41Sopenharmony_ci return { 1941cb0ef41Sopenharmony_ci ...res, 1951cb0ef41Sopenharmony_ci openedUrls: () => openedUrls, 1961cb0ef41Sopenharmony_ci fund: (...args) => res.npm.exec('fund', args), 1971cb0ef41Sopenharmony_ci } 1981cb0ef41Sopenharmony_ci} 1991cb0ef41Sopenharmony_ci 2001cb0ef41Sopenharmony_cit.test('fund with no package containing funding', async t => { 2011cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 2021cb0ef41Sopenharmony_ci prefixDir: { 2031cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 2041cb0ef41Sopenharmony_ci name: 'no-funding-package', 2051cb0ef41Sopenharmony_ci version: '0.0.0', 2061cb0ef41Sopenharmony_ci }), 2071cb0ef41Sopenharmony_ci }, 2081cb0ef41Sopenharmony_ci config: {}, 2091cb0ef41Sopenharmony_ci }) 2101cb0ef41Sopenharmony_ci 2111cb0ef41Sopenharmony_ci await fund() 2121cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print empty funding info') 2131cb0ef41Sopenharmony_ci}) 2141cb0ef41Sopenharmony_ci 2151cb0ef41Sopenharmony_cit.test('fund in which same maintainer owns all its deps', async t => { 2161cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 2171cb0ef41Sopenharmony_ci prefixDir: maintainerOwnsAllDeps, 2181cb0ef41Sopenharmony_ci config: {}, 2191cb0ef41Sopenharmony_ci }) 2201cb0ef41Sopenharmony_ci 2211cb0ef41Sopenharmony_ci await fund() 2221cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print stack packages together') 2231cb0ef41Sopenharmony_ci}) 2241cb0ef41Sopenharmony_ci 2251cb0ef41Sopenharmony_cit.test('fund in which same maintainer owns all its deps, using --json option', async t => { 2261cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 2271cb0ef41Sopenharmony_ci prefixDir: maintainerOwnsAllDeps, 2281cb0ef41Sopenharmony_ci config: { json: true }, 2291cb0ef41Sopenharmony_ci }) 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci await fund() 2321cb0ef41Sopenharmony_ci t.same( 2331cb0ef41Sopenharmony_ci JSON.parse(joinedOutput()), 2341cb0ef41Sopenharmony_ci { 2351cb0ef41Sopenharmony_ci length: 3, 2361cb0ef41Sopenharmony_ci name: 'maintainer-owns-all-deps', 2371cb0ef41Sopenharmony_ci version: '1.0.0', 2381cb0ef41Sopenharmony_ci funding: { type: 'individual', url: 'http://example.com/donate' }, 2391cb0ef41Sopenharmony_ci dependencies: { 2401cb0ef41Sopenharmony_ci 'dep-bar': { 2411cb0ef41Sopenharmony_ci version: '1.0.0', 2421cb0ef41Sopenharmony_ci funding: { type: 'individual', url: 'http://example.com/donate' }, 2431cb0ef41Sopenharmony_ci }, 2441cb0ef41Sopenharmony_ci 'dep-foo': { 2451cb0ef41Sopenharmony_ci version: '1.0.0', 2461cb0ef41Sopenharmony_ci funding: { type: 'individual', url: 'http://example.com/donate' }, 2471cb0ef41Sopenharmony_ci dependencies: { 2481cb0ef41Sopenharmony_ci 'dep-sub-foo': { 2491cb0ef41Sopenharmony_ci version: '1.0.0', 2501cb0ef41Sopenharmony_ci funding: { type: 'individual', url: 'http://example.com/donate' }, 2511cb0ef41Sopenharmony_ci }, 2521cb0ef41Sopenharmony_ci }, 2531cb0ef41Sopenharmony_ci }, 2541cb0ef41Sopenharmony_ci }, 2551cb0ef41Sopenharmony_ci }, 2561cb0ef41Sopenharmony_ci 'should print stack packages together' 2571cb0ef41Sopenharmony_ci ) 2581cb0ef41Sopenharmony_ci}) 2591cb0ef41Sopenharmony_ci 2601cb0ef41Sopenharmony_cit.test('fund containing multi-level nested deps with no funding', async t => { 2611cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 2621cb0ef41Sopenharmony_ci prefixDir: nestedNoFundingPackages, 2631cb0ef41Sopenharmony_ci config: {}, 2641cb0ef41Sopenharmony_ci }) 2651cb0ef41Sopenharmony_ci 2661cb0ef41Sopenharmony_ci await fund() 2671cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should omit dependencies with no funding declared') 2681cb0ef41Sopenharmony_ci}) 2691cb0ef41Sopenharmony_ci 2701cb0ef41Sopenharmony_cit.test('fund containing multi-level nested deps with no funding, using --json option', async t => { 2711cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 2721cb0ef41Sopenharmony_ci prefixDir: nestedNoFundingPackages, 2731cb0ef41Sopenharmony_ci config: { json: true }, 2741cb0ef41Sopenharmony_ci }) 2751cb0ef41Sopenharmony_ci 2761cb0ef41Sopenharmony_ci await fund() 2771cb0ef41Sopenharmony_ci t.same( 2781cb0ef41Sopenharmony_ci JSON.parse(joinedOutput()), 2791cb0ef41Sopenharmony_ci { 2801cb0ef41Sopenharmony_ci length: 2, 2811cb0ef41Sopenharmony_ci name: 'nested-no-funding-packages', 2821cb0ef41Sopenharmony_ci version: '1.0.0', 2831cb0ef41Sopenharmony_ci dependencies: { 2841cb0ef41Sopenharmony_ci lorem: { 2851cb0ef41Sopenharmony_ci version: '1.0.0', 2861cb0ef41Sopenharmony_ci funding: { url: 'https://example.com/lorem' }, 2871cb0ef41Sopenharmony_ci }, 2881cb0ef41Sopenharmony_ci bar: { 2891cb0ef41Sopenharmony_ci version: '1.0.0', 2901cb0ef41Sopenharmony_ci funding: { type: 'individual', url: 'http://example.com/donate' }, 2911cb0ef41Sopenharmony_ci }, 2921cb0ef41Sopenharmony_ci }, 2931cb0ef41Sopenharmony_ci }, 2941cb0ef41Sopenharmony_ci 'should omit dependencies with no funding declared in json output' 2951cb0ef41Sopenharmony_ci ) 2961cb0ef41Sopenharmony_ci}) 2971cb0ef41Sopenharmony_ci 2981cb0ef41Sopenharmony_cit.test('fund containing multi-level nested deps with no funding, using --json option', async t => { 2991cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 3001cb0ef41Sopenharmony_ci prefixDir: nestedMultipleFundingPackages, 3011cb0ef41Sopenharmony_ci config: { json: true }, 3021cb0ef41Sopenharmony_ci }) 3031cb0ef41Sopenharmony_ci 3041cb0ef41Sopenharmony_ci await fund() 3051cb0ef41Sopenharmony_ci t.same( 3061cb0ef41Sopenharmony_ci JSON.parse(joinedOutput()), 3071cb0ef41Sopenharmony_ci { 3081cb0ef41Sopenharmony_ci length: 2, 3091cb0ef41Sopenharmony_ci name: 'nested-multiple-funding-packages', 3101cb0ef41Sopenharmony_ci version: '1.0.0', 3111cb0ef41Sopenharmony_ci funding: [ 3121cb0ef41Sopenharmony_ci { 3131cb0ef41Sopenharmony_ci url: 'https://one.example.com', 3141cb0ef41Sopenharmony_ci }, 3151cb0ef41Sopenharmony_ci { 3161cb0ef41Sopenharmony_ci url: 'https://two.example.com', 3171cb0ef41Sopenharmony_ci }, 3181cb0ef41Sopenharmony_ci ], 3191cb0ef41Sopenharmony_ci dependencies: { 3201cb0ef41Sopenharmony_ci bar: { 3211cb0ef41Sopenharmony_ci version: '1.0.0', 3221cb0ef41Sopenharmony_ci funding: [ 3231cb0ef41Sopenharmony_ci { 3241cb0ef41Sopenharmony_ci url: 'http://collective.example.com', 3251cb0ef41Sopenharmony_ci }, 3261cb0ef41Sopenharmony_ci { 3271cb0ef41Sopenharmony_ci url: 'http://sponsors.example.com/you', 3281cb0ef41Sopenharmony_ci }, 3291cb0ef41Sopenharmony_ci ], 3301cb0ef41Sopenharmony_ci }, 3311cb0ef41Sopenharmony_ci foo: { 3321cb0ef41Sopenharmony_ci version: '1.0.0', 3331cb0ef41Sopenharmony_ci funding: [ 3341cb0ef41Sopenharmony_ci { 3351cb0ef41Sopenharmony_ci url: 'http://example.com', 3361cb0ef41Sopenharmony_ci }, 3371cb0ef41Sopenharmony_ci { 3381cb0ef41Sopenharmony_ci url: 'http://sponsors.example.com/me', 3391cb0ef41Sopenharmony_ci }, 3401cb0ef41Sopenharmony_ci { 3411cb0ef41Sopenharmony_ci url: 'http://collective.example.com', 3421cb0ef41Sopenharmony_ci }, 3431cb0ef41Sopenharmony_ci ], 3441cb0ef41Sopenharmony_ci }, 3451cb0ef41Sopenharmony_ci }, 3461cb0ef41Sopenharmony_ci }, 3471cb0ef41Sopenharmony_ci 'should list multiple funding entries in json output' 3481cb0ef41Sopenharmony_ci ) 3491cb0ef41Sopenharmony_ci}) 3501cb0ef41Sopenharmony_ci 3511cb0ef41Sopenharmony_cit.test('fund does not support global', async t => { 3521cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 3531cb0ef41Sopenharmony_ci config: { global: true }, 3541cb0ef41Sopenharmony_ci }) 3551cb0ef41Sopenharmony_ci 3561cb0ef41Sopenharmony_ci await t.rejects(fund(), { code: 'EFUNDGLOBAL' }, 'should throw EFUNDGLOBAL error') 3571cb0ef41Sopenharmony_ci}) 3581cb0ef41Sopenharmony_ci 3591cb0ef41Sopenharmony_cit.test('fund using package argument', async t => { 3601cb0ef41Sopenharmony_ci const { fund, openedUrls, joinedOutput } = await setup(t, { 3611cb0ef41Sopenharmony_ci prefixDir: maintainerOwnsAllDeps, 3621cb0ef41Sopenharmony_ci config: {}, 3631cb0ef41Sopenharmony_ci }) 3641cb0ef41Sopenharmony_ci 3651cb0ef41Sopenharmony_ci await fund('.') 3661cb0ef41Sopenharmony_ci t.equal(joinedOutput(), '') 3671cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), ['http://example.com/donate'], 'should open funding url') 3681cb0ef41Sopenharmony_ci}) 3691cb0ef41Sopenharmony_ci 3701cb0ef41Sopenharmony_cit.test('fund does not support global, using --json option', async t => { 3711cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 3721cb0ef41Sopenharmony_ci prefixDir: {}, 3731cb0ef41Sopenharmony_ci config: { global: true, json: true }, 3741cb0ef41Sopenharmony_ci }) 3751cb0ef41Sopenharmony_ci 3761cb0ef41Sopenharmony_ci await t.rejects( 3771cb0ef41Sopenharmony_ci fund(), 3781cb0ef41Sopenharmony_ci { code: 'EFUNDGLOBAL', message: '`npm fund` does not support global packages' }, 3791cb0ef41Sopenharmony_ci 'should use expected error msg' 3801cb0ef41Sopenharmony_ci ) 3811cb0ef41Sopenharmony_ci}) 3821cb0ef41Sopenharmony_ci 3831cb0ef41Sopenharmony_cit.test('fund using string shorthand', async t => { 3841cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 3851cb0ef41Sopenharmony_ci prefixDir: { 3861cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 3871cb0ef41Sopenharmony_ci name: 'funding-string-shorthand', 3881cb0ef41Sopenharmony_ci version: '0.0.0', 3891cb0ef41Sopenharmony_ci funding: 'https://example.com/sponsor', 3901cb0ef41Sopenharmony_ci }), 3911cb0ef41Sopenharmony_ci }, 3921cb0ef41Sopenharmony_ci config: {}, 3931cb0ef41Sopenharmony_ci }) 3941cb0ef41Sopenharmony_ci 3951cb0ef41Sopenharmony_ci await fund('.') 3961cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), ['https://example.com/sponsor'], 'should open string-only url') 3971cb0ef41Sopenharmony_ci}) 3981cb0ef41Sopenharmony_ci 3991cb0ef41Sopenharmony_cit.test('fund using nested packages with multiple sources', async t => { 4001cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 4011cb0ef41Sopenharmony_ci prefixDir: nestedMultipleFundingPackages, 4021cb0ef41Sopenharmony_ci config: {}, 4031cb0ef41Sopenharmony_ci }) 4041cb0ef41Sopenharmony_ci 4051cb0ef41Sopenharmony_ci await fund('.') 4061cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should prompt with all available URLs') 4071cb0ef41Sopenharmony_ci}) 4081cb0ef41Sopenharmony_ci 4091cb0ef41Sopenharmony_cit.test('fund using symlink ref', async t => { 4101cb0ef41Sopenharmony_ci const f = 'http://example.com/a' 4111cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 4121cb0ef41Sopenharmony_ci prefixDir: { 4131cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4141cb0ef41Sopenharmony_ci name: 'using-symlink-ref', 4151cb0ef41Sopenharmony_ci version: '1.0.0', 4161cb0ef41Sopenharmony_ci }), 4171cb0ef41Sopenharmony_ci a: { 4181cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4191cb0ef41Sopenharmony_ci name: 'a', 4201cb0ef41Sopenharmony_ci version: '1.0.0', 4211cb0ef41Sopenharmony_ci funding: f, 4221cb0ef41Sopenharmony_ci }), 4231cb0ef41Sopenharmony_ci }, 4241cb0ef41Sopenharmony_ci node_modules: { 4251cb0ef41Sopenharmony_ci a: t.fixture('symlink', '../a'), 4261cb0ef41Sopenharmony_ci }, 4271cb0ef41Sopenharmony_ci }, 4281cb0ef41Sopenharmony_ci config: {}, 4291cb0ef41Sopenharmony_ci }) 4301cb0ef41Sopenharmony_ci 4311cb0ef41Sopenharmony_ci // using symlinked ref 4321cb0ef41Sopenharmony_ci await fund('./node_modules/a') 4331cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), [f], 'should retrieve funding url from symlink') 4341cb0ef41Sopenharmony_ci 4351cb0ef41Sopenharmony_ci // using target ref 4361cb0ef41Sopenharmony_ci await fund('./a') 4371cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), [f, f], 'should retrieve funding url from symlink target') 4381cb0ef41Sopenharmony_ci}) 4391cb0ef41Sopenharmony_ci 4401cb0ef41Sopenharmony_cit.test('fund using data from actual tree', async t => { 4411cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 4421cb0ef41Sopenharmony_ci prefixDir: { 4431cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4441cb0ef41Sopenharmony_ci name: 'using-actual-tree', 4451cb0ef41Sopenharmony_ci version: '1.0.0', 4461cb0ef41Sopenharmony_ci }), 4471cb0ef41Sopenharmony_ci node_modules: { 4481cb0ef41Sopenharmony_ci a: { 4491cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4501cb0ef41Sopenharmony_ci name: 'a', 4511cb0ef41Sopenharmony_ci version: '1.0.0', 4521cb0ef41Sopenharmony_ci funding: 'http://example.com/a', 4531cb0ef41Sopenharmony_ci }), 4541cb0ef41Sopenharmony_ci }, 4551cb0ef41Sopenharmony_ci b: { 4561cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4571cb0ef41Sopenharmony_ci name: 'a', 4581cb0ef41Sopenharmony_ci version: '1.0.0', 4591cb0ef41Sopenharmony_ci funding: 'http://example.com/b', 4601cb0ef41Sopenharmony_ci }), 4611cb0ef41Sopenharmony_ci node_modules: { 4621cb0ef41Sopenharmony_ci a: { 4631cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 4641cb0ef41Sopenharmony_ci name: 'a', 4651cb0ef41Sopenharmony_ci version: '1.0.1', 4661cb0ef41Sopenharmony_ci funding: 'http://example.com/_AAA', 4671cb0ef41Sopenharmony_ci }), 4681cb0ef41Sopenharmony_ci }, 4691cb0ef41Sopenharmony_ci }, 4701cb0ef41Sopenharmony_ci }, 4711cb0ef41Sopenharmony_ci }, 4721cb0ef41Sopenharmony_ci }, 4731cb0ef41Sopenharmony_ci config: {}, 4741cb0ef41Sopenharmony_ci }) 4751cb0ef41Sopenharmony_ci 4761cb0ef41Sopenharmony_ci // using symlinked ref 4771cb0ef41Sopenharmony_ci await fund('a') 4781cb0ef41Sopenharmony_ci t.strictSame( 4791cb0ef41Sopenharmony_ci openedUrls(), 4801cb0ef41Sopenharmony_ci ['http://example.com/_AAA'], 4811cb0ef41Sopenharmony_ci 'should retrieve fund info from actual tree, using greatest version found' 4821cb0ef41Sopenharmony_ci ) 4831cb0ef41Sopenharmony_ci}) 4841cb0ef41Sopenharmony_ci 4851cb0ef41Sopenharmony_cit.test('fund using nested packages with multiple sources, with a source number', async t => { 4861cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 4871cb0ef41Sopenharmony_ci prefixDir: nestedMultipleFundingPackages, 4881cb0ef41Sopenharmony_ci config: { which: '1' }, 4891cb0ef41Sopenharmony_ci }) 4901cb0ef41Sopenharmony_ci 4911cb0ef41Sopenharmony_ci await fund('.') 4921cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), ['https://one.example.com'], 'should open the numbered URL') 4931cb0ef41Sopenharmony_ci}) 4941cb0ef41Sopenharmony_ci 4951cb0ef41Sopenharmony_cit.test('fund using pkg name while having conflicting versions', async t => { 4961cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 4971cb0ef41Sopenharmony_ci prefixDir: conflictingFundingPackages, 4981cb0ef41Sopenharmony_ci config: { which: '1' }, 4991cb0ef41Sopenharmony_ci }) 5001cb0ef41Sopenharmony_ci 5011cb0ef41Sopenharmony_ci await fund('foo') 5021cb0ef41Sopenharmony_ci t.strictSame(openedUrls(), ['http://example.com/2'], 'should open greatest version') 5031cb0ef41Sopenharmony_ci}) 5041cb0ef41Sopenharmony_ci 5051cb0ef41Sopenharmony_cit.test('fund using bad which value: index too high', async t => { 5061cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 5071cb0ef41Sopenharmony_ci prefixDir: nestedMultipleFundingPackages, 5081cb0ef41Sopenharmony_ci config: { which: '100' }, 5091cb0ef41Sopenharmony_ci }) 5101cb0ef41Sopenharmony_ci 5111cb0ef41Sopenharmony_ci await fund('foo') 5121cb0ef41Sopenharmony_ci t.match(joinedOutput(), 'not a valid index') 5131cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print message about invalid which') 5141cb0ef41Sopenharmony_ci}) 5151cb0ef41Sopenharmony_ci 5161cb0ef41Sopenharmony_cit.test('fund using package argument with no browser, using --json option', async t => { 5171cb0ef41Sopenharmony_ci const { fund, openedUrls, joinedOutput } = await setup(t, { 5181cb0ef41Sopenharmony_ci prefixDir: maintainerOwnsAllDeps, 5191cb0ef41Sopenharmony_ci config: { json: true }, 5201cb0ef41Sopenharmony_ci }) 5211cb0ef41Sopenharmony_ci 5221cb0ef41Sopenharmony_ci await fund('.') 5231cb0ef41Sopenharmony_ci t.equal(joinedOutput(), '', 'no output') 5241cb0ef41Sopenharmony_ci t.same( 5251cb0ef41Sopenharmony_ci openedUrls(), 5261cb0ef41Sopenharmony_ci ['http://example.com/donate'], 5271cb0ef41Sopenharmony_ci 'should open funding url using json output' 5281cb0ef41Sopenharmony_ci ) 5291cb0ef41Sopenharmony_ci}) 5301cb0ef41Sopenharmony_ci 5311cb0ef41Sopenharmony_cit.test('fund using package info fetch from registry', async t => { 5321cb0ef41Sopenharmony_ci const { fund, openedUrls } = await setup(t, { 5331cb0ef41Sopenharmony_ci prefixDir: {}, 5341cb0ef41Sopenharmony_ci config: {}, 5351cb0ef41Sopenharmony_ci }) 5361cb0ef41Sopenharmony_ci 5371cb0ef41Sopenharmony_ci await fund('ntl') 5381cb0ef41Sopenharmony_ci t.match( 5391cb0ef41Sopenharmony_ci openedUrls(), 5401cb0ef41Sopenharmony_ci /http:\/\/example.com\/pacote/, 5411cb0ef41Sopenharmony_ci 'should open funding url that was loaded from registry manifest' 5421cb0ef41Sopenharmony_ci ) 5431cb0ef41Sopenharmony_ci}) 5441cb0ef41Sopenharmony_ci 5451cb0ef41Sopenharmony_cit.test('fund tries to use package info fetch from registry but registry has nothing', async t => { 5461cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 5471cb0ef41Sopenharmony_ci prefixDir: {}, 5481cb0ef41Sopenharmony_ci config: {}, 5491cb0ef41Sopenharmony_ci }) 5501cb0ef41Sopenharmony_ci 5511cb0ef41Sopenharmony_ci await t.rejects( 5521cb0ef41Sopenharmony_ci fund('foo'), 5531cb0ef41Sopenharmony_ci { code: 'ENOFUND', message: 'No valid funding method available for: foo' }, 5541cb0ef41Sopenharmony_ci 'should have no valid funding message' 5551cb0ef41Sopenharmony_ci ) 5561cb0ef41Sopenharmony_ci}) 5571cb0ef41Sopenharmony_ci 5581cb0ef41Sopenharmony_cit.test('fund but target module has no funding info', async t => { 5591cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 5601cb0ef41Sopenharmony_ci prefixDir: nestedNoFundingPackages, 5611cb0ef41Sopenharmony_ci config: {}, 5621cb0ef41Sopenharmony_ci }) 5631cb0ef41Sopenharmony_ci 5641cb0ef41Sopenharmony_ci await t.rejects( 5651cb0ef41Sopenharmony_ci fund('foo'), 5661cb0ef41Sopenharmony_ci { code: 'ENOFUND', message: 'No valid funding method available for: foo' }, 5671cb0ef41Sopenharmony_ci 'should have no valid funding message' 5681cb0ef41Sopenharmony_ci ) 5691cb0ef41Sopenharmony_ci}) 5701cb0ef41Sopenharmony_ci 5711cb0ef41Sopenharmony_cit.test('fund using bad which value', async t => { 5721cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 5731cb0ef41Sopenharmony_ci prefixDir: nestedMultipleFundingPackages, 5741cb0ef41Sopenharmony_ci config: { which: '0' }, 5751cb0ef41Sopenharmony_ci }) 5761cb0ef41Sopenharmony_ci 5771cb0ef41Sopenharmony_ci await t.rejects( 5781cb0ef41Sopenharmony_ci fund('bar'), 5791cb0ef41Sopenharmony_ci { 5801cb0ef41Sopenharmony_ci code: 'EFUNDNUMBER', 5811cb0ef41Sopenharmony_ci message: /must be given a positive integer/, 5821cb0ef41Sopenharmony_ci }, 5831cb0ef41Sopenharmony_ci 'should have bad which option error message' 5841cb0ef41Sopenharmony_ci ) 5851cb0ef41Sopenharmony_ci}) 5861cb0ef41Sopenharmony_ci 5871cb0ef41Sopenharmony_cit.test('fund pkg missing version number', async t => { 5881cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 5891cb0ef41Sopenharmony_ci prefixDir: { 5901cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 5911cb0ef41Sopenharmony_ci name: 'foo', 5921cb0ef41Sopenharmony_ci funding: 'http://example.com/foo', 5931cb0ef41Sopenharmony_ci }), 5941cb0ef41Sopenharmony_ci }, 5951cb0ef41Sopenharmony_ci config: {}, 5961cb0ef41Sopenharmony_ci }) 5971cb0ef41Sopenharmony_ci 5981cb0ef41Sopenharmony_ci await fund() 5991cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print name only') 6001cb0ef41Sopenharmony_ci}) 6011cb0ef41Sopenharmony_ci 6021cb0ef41Sopenharmony_cit.test('fund a package throws on openUrl', async t => { 6031cb0ef41Sopenharmony_ci const { fund } = await setup(t, { 6041cb0ef41Sopenharmony_ci prefixDir: { 6051cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6061cb0ef41Sopenharmony_ci name: 'foo', 6071cb0ef41Sopenharmony_ci version: '1.0.0', 6081cb0ef41Sopenharmony_ci funding: 'http://npmjs.org', 6091cb0ef41Sopenharmony_ci }), 6101cb0ef41Sopenharmony_ci }, 6111cb0ef41Sopenharmony_ci config: {}, 6121cb0ef41Sopenharmony_ci openUrl: () => { 6131cb0ef41Sopenharmony_ci throw new Error('ERROR') 6141cb0ef41Sopenharmony_ci }, 6151cb0ef41Sopenharmony_ci }) 6161cb0ef41Sopenharmony_ci 6171cb0ef41Sopenharmony_ci await t.rejects(fund('.'), { message: 'ERROR' }, 'should throw unknown error') 6181cb0ef41Sopenharmony_ci}) 6191cb0ef41Sopenharmony_ci 6201cb0ef41Sopenharmony_cit.test('fund a package with type and multiple sources', async t => { 6211cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 6221cb0ef41Sopenharmony_ci prefixDir: { 6231cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6241cb0ef41Sopenharmony_ci name: 'foo', 6251cb0ef41Sopenharmony_ci funding: [ 6261cb0ef41Sopenharmony_ci { 6271cb0ef41Sopenharmony_ci type: 'Foo', 6281cb0ef41Sopenharmony_ci url: 'http://example.com/foo', 6291cb0ef41Sopenharmony_ci }, 6301cb0ef41Sopenharmony_ci { 6311cb0ef41Sopenharmony_ci type: 'Lorem', 6321cb0ef41Sopenharmony_ci url: 'http://example.com/foo-lorem', 6331cb0ef41Sopenharmony_ci }, 6341cb0ef41Sopenharmony_ci ], 6351cb0ef41Sopenharmony_ci }), 6361cb0ef41Sopenharmony_ci }, 6371cb0ef41Sopenharmony_ci config: {}, 6381cb0ef41Sopenharmony_ci }) 6391cb0ef41Sopenharmony_ci 6401cb0ef41Sopenharmony_ci await fund('.') 6411cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print prompt select message') 6421cb0ef41Sopenharmony_ci}) 6431cb0ef41Sopenharmony_ci 6441cb0ef41Sopenharmony_cit.test('fund colors', async t => { 6451cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 6461cb0ef41Sopenharmony_ci prefixDir: { 6471cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6481cb0ef41Sopenharmony_ci name: 'test-fund-colors', 6491cb0ef41Sopenharmony_ci version: '1.0.0', 6501cb0ef41Sopenharmony_ci dependencies: { 6511cb0ef41Sopenharmony_ci a: '^1.0.0', 6521cb0ef41Sopenharmony_ci b: '^1.0.0', 6531cb0ef41Sopenharmony_ci c: '^1.0.0', 6541cb0ef41Sopenharmony_ci }, 6551cb0ef41Sopenharmony_ci }), 6561cb0ef41Sopenharmony_ci node_modules: { 6571cb0ef41Sopenharmony_ci a: { 6581cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6591cb0ef41Sopenharmony_ci name: 'a', 6601cb0ef41Sopenharmony_ci version: '1.0.0', 6611cb0ef41Sopenharmony_ci funding: 'http://example.com/a', 6621cb0ef41Sopenharmony_ci }), 6631cb0ef41Sopenharmony_ci }, 6641cb0ef41Sopenharmony_ci b: { 6651cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6661cb0ef41Sopenharmony_ci name: 'b', 6671cb0ef41Sopenharmony_ci version: '1.0.0', 6681cb0ef41Sopenharmony_ci funding: 'http://example.com/b', 6691cb0ef41Sopenharmony_ci dependencies: { 6701cb0ef41Sopenharmony_ci d: '^1.0.0', 6711cb0ef41Sopenharmony_ci e: '^1.0.0', 6721cb0ef41Sopenharmony_ci }, 6731cb0ef41Sopenharmony_ci }), 6741cb0ef41Sopenharmony_ci }, 6751cb0ef41Sopenharmony_ci c: { 6761cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6771cb0ef41Sopenharmony_ci name: 'c', 6781cb0ef41Sopenharmony_ci version: '1.0.0', 6791cb0ef41Sopenharmony_ci funding: 'http://example.com/b', 6801cb0ef41Sopenharmony_ci }), 6811cb0ef41Sopenharmony_ci }, 6821cb0ef41Sopenharmony_ci d: { 6831cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6841cb0ef41Sopenharmony_ci name: 'd', 6851cb0ef41Sopenharmony_ci version: '1.0.0', 6861cb0ef41Sopenharmony_ci funding: 'http://example.com/d', 6871cb0ef41Sopenharmony_ci }), 6881cb0ef41Sopenharmony_ci }, 6891cb0ef41Sopenharmony_ci e: { 6901cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 6911cb0ef41Sopenharmony_ci name: 'e', 6921cb0ef41Sopenharmony_ci version: '1.0.0', 6931cb0ef41Sopenharmony_ci funding: 'http://example.com/e', 6941cb0ef41Sopenharmony_ci }), 6951cb0ef41Sopenharmony_ci }, 6961cb0ef41Sopenharmony_ci }, 6971cb0ef41Sopenharmony_ci }, 6981cb0ef41Sopenharmony_ci config: { color: 'always' }, 6991cb0ef41Sopenharmony_ci }) 7001cb0ef41Sopenharmony_ci 7011cb0ef41Sopenharmony_ci await fund() 7021cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should print output with color info') 7031cb0ef41Sopenharmony_ci}) 7041cb0ef41Sopenharmony_ci 7051cb0ef41Sopenharmony_cit.test('sub dep with fund info and a parent with no funding info', async t => { 7061cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 7071cb0ef41Sopenharmony_ci prefixDir: { 7081cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7091cb0ef41Sopenharmony_ci name: 'test-multiple-funding-sources', 7101cb0ef41Sopenharmony_ci version: '1.0.0', 7111cb0ef41Sopenharmony_ci dependencies: { 7121cb0ef41Sopenharmony_ci a: '^1.0.0', 7131cb0ef41Sopenharmony_ci b: '^1.0.0', 7141cb0ef41Sopenharmony_ci }, 7151cb0ef41Sopenharmony_ci }), 7161cb0ef41Sopenharmony_ci node_modules: { 7171cb0ef41Sopenharmony_ci a: { 7181cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7191cb0ef41Sopenharmony_ci name: 'a', 7201cb0ef41Sopenharmony_ci version: '1.0.0', 7211cb0ef41Sopenharmony_ci dependencies: { 7221cb0ef41Sopenharmony_ci c: '^1.0.0', 7231cb0ef41Sopenharmony_ci }, 7241cb0ef41Sopenharmony_ci }), 7251cb0ef41Sopenharmony_ci }, 7261cb0ef41Sopenharmony_ci b: { 7271cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7281cb0ef41Sopenharmony_ci name: 'b', 7291cb0ef41Sopenharmony_ci version: '1.0.0', 7301cb0ef41Sopenharmony_ci funding: 'http://example.com/b', 7311cb0ef41Sopenharmony_ci }), 7321cb0ef41Sopenharmony_ci }, 7331cb0ef41Sopenharmony_ci c: { 7341cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7351cb0ef41Sopenharmony_ci name: 'c', 7361cb0ef41Sopenharmony_ci version: '1.0.0', 7371cb0ef41Sopenharmony_ci funding: ['http://example.com/c', 'http://example.com/c-other'], 7381cb0ef41Sopenharmony_ci }), 7391cb0ef41Sopenharmony_ci }, 7401cb0ef41Sopenharmony_ci }, 7411cb0ef41Sopenharmony_ci }, 7421cb0ef41Sopenharmony_ci config: {}, 7431cb0ef41Sopenharmony_ci }) 7441cb0ef41Sopenharmony_ci 7451cb0ef41Sopenharmony_ci await fund() 7461cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should nest sub dep as child of root') 7471cb0ef41Sopenharmony_ci}) 7481cb0ef41Sopenharmony_ci 7491cb0ef41Sopenharmony_cit.test('workspaces', async t => { 7501cb0ef41Sopenharmony_ci const wsPrefixDir = { 7511cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7521cb0ef41Sopenharmony_ci name: 'workspaces-support', 7531cb0ef41Sopenharmony_ci version: '1.0.0', 7541cb0ef41Sopenharmony_ci workspaces: ['packages/*'], 7551cb0ef41Sopenharmony_ci dependencies: { 7561cb0ef41Sopenharmony_ci d: '^1.0.0', 7571cb0ef41Sopenharmony_ci }, 7581cb0ef41Sopenharmony_ci }), 7591cb0ef41Sopenharmony_ci node_modules: { 7601cb0ef41Sopenharmony_ci a: t.fixture('symlink', '../packages/a'), 7611cb0ef41Sopenharmony_ci b: t.fixture('symlink', '../packages/b'), 7621cb0ef41Sopenharmony_ci c: { 7631cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7641cb0ef41Sopenharmony_ci name: 'c', 7651cb0ef41Sopenharmony_ci version: '1.0.0', 7661cb0ef41Sopenharmony_ci funding: ['http://example.com/c', 'http://example.com/c-other'], 7671cb0ef41Sopenharmony_ci }), 7681cb0ef41Sopenharmony_ci }, 7691cb0ef41Sopenharmony_ci d: { 7701cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7711cb0ef41Sopenharmony_ci name: 'd', 7721cb0ef41Sopenharmony_ci version: '1.0.0', 7731cb0ef41Sopenharmony_ci funding: 'http://example.com/d', 7741cb0ef41Sopenharmony_ci }), 7751cb0ef41Sopenharmony_ci }, 7761cb0ef41Sopenharmony_ci }, 7771cb0ef41Sopenharmony_ci packages: { 7781cb0ef41Sopenharmony_ci a: { 7791cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7801cb0ef41Sopenharmony_ci name: 'a', 7811cb0ef41Sopenharmony_ci version: '1.0.0', 7821cb0ef41Sopenharmony_ci funding: 'https://example.com/a', 7831cb0ef41Sopenharmony_ci dependencies: { 7841cb0ef41Sopenharmony_ci c: '^1.0.0', 7851cb0ef41Sopenharmony_ci }, 7861cb0ef41Sopenharmony_ci }), 7871cb0ef41Sopenharmony_ci }, 7881cb0ef41Sopenharmony_ci b: { 7891cb0ef41Sopenharmony_ci 'package.json': JSON.stringify({ 7901cb0ef41Sopenharmony_ci name: 'b', 7911cb0ef41Sopenharmony_ci version: '1.0.0', 7921cb0ef41Sopenharmony_ci funding: 'http://example.com/b', 7931cb0ef41Sopenharmony_ci dependencies: { 7941cb0ef41Sopenharmony_ci d: '^1.0.0', 7951cb0ef41Sopenharmony_ci }, 7961cb0ef41Sopenharmony_ci }), 7971cb0ef41Sopenharmony_ci }, 7981cb0ef41Sopenharmony_ci }, 7991cb0ef41Sopenharmony_ci } 8001cb0ef41Sopenharmony_ci 8011cb0ef41Sopenharmony_ci t.test('filter funding info by a specific workspace name', async t => { 8021cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 8031cb0ef41Sopenharmony_ci prefixDir: wsPrefixDir, 8041cb0ef41Sopenharmony_ci config: { 8051cb0ef41Sopenharmony_ci workspace: 'a', 8061cb0ef41Sopenharmony_ci }, 8071cb0ef41Sopenharmony_ci }) 8081cb0ef41Sopenharmony_ci 8091cb0ef41Sopenharmony_ci await fund() 8101cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should display only filtered workspace name and its deps') 8111cb0ef41Sopenharmony_ci }) 8121cb0ef41Sopenharmony_ci 8131cb0ef41Sopenharmony_ci t.test('filter funding info by a specific workspace path', async t => { 8141cb0ef41Sopenharmony_ci const { fund, joinedOutput } = await setup(t, { 8151cb0ef41Sopenharmony_ci prefixDir: wsPrefixDir, 8161cb0ef41Sopenharmony_ci config: { 8171cb0ef41Sopenharmony_ci workspace: './packages/a', 8181cb0ef41Sopenharmony_ci }, 8191cb0ef41Sopenharmony_ci }) 8201cb0ef41Sopenharmony_ci 8211cb0ef41Sopenharmony_ci await fund() 8221cb0ef41Sopenharmony_ci t.matchSnapshot(joinedOutput(), 'should display only filtered workspace name and its deps') 8231cb0ef41Sopenharmony_ci }) 8241cb0ef41Sopenharmony_ci}) 825