diff --git a/__test__/after-task.spec.js b/__test__/after-task.spec.js index 4d430f6..7bff727 100644 --- a/__test__/after-task.spec.js +++ b/__test__/after-task.spec.js @@ -6,7 +6,7 @@ ansiColors.inverse = ansiColors; ansiColors.underline = ansiColors; ansiColors.bold = ansiColors; -const isAvailable = bin => bin === 'yarn'; +const isAvailable = bin => bin === 'yarn' || bin === 'pnpm'; test('"after" task only prints summary in unattended mode', async t => { const prompts = { @@ -79,10 +79,49 @@ test('"after" task only prints summary in unattended mode and here mode', async ); }); +test('"after" task installs deps with npm, and prints summary', async t => { + const prompts = { + select(opts) { + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); + return 'npm'; + } + }; + + function run(cmd, args) { + t.is(cmd, 'npm'); + t.deepEqual(args, ['install']); + } + + let printOut = ''; + await after({ + unattended: false, + here: false, + prompts, + run, + properties: {name: 'my-app'}, + features: ['a', 'b'], + notDefaultFeatures: ['a', 'b-c'], + ansiColors + }, { + _isAvailable: isAvailable, + _log(m) { + printOut += m + '\n'; + } + }); + + t.is(printOut, + '\nNext time, you can try to create similar project in silent mode:\n' + + ' npx makes aurelia new-project-name -s a,b-c \n\n' + + 'Get Started\n' + + 'cd my-app\n' + + 'npm start\n\n' + ); +}); + test('"after" task installs deps with yarn, and prints summary', async t => { const prompts = { select(opts) { - t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn']); + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); return 'yarn'; } }; @@ -118,6 +157,45 @@ test('"after" task installs deps with yarn, and prints summary', async t => { ); }); +test('"after" task installs deps with pnpm, and prints summary', async t => { + const prompts = { + select(opts) { + t.deepEqual(opts.choices.map(c => c.value), [undefined, 'npm', 'yarn', 'pnpm']); + return 'pnpm'; + } + }; + + function run(cmd, args) { + t.is(cmd, 'pnpm'); + t.deepEqual(args, ['install']); + } + + let printOut = ''; + await after({ + unattended: false, + here: false, + prompts, + run, + properties: {name: 'my-app'}, + features: ['a', 'b'], + notDefaultFeatures: ['a', 'b-c'], + ansiColors + }, { + _isAvailable: isAvailable, + _log(m) { + printOut += m + '\n'; + } + }); + + t.is(printOut, + '\nNext time, you can try to create similar project in silent mode:\n' + + ' npx makes aurelia new-project-name -s a,b-c \n\n' + + 'Get Started\n' + + 'cd my-app\n' + + 'pnpm start\n\n' + ); +}); + test('"after" task installs deps, and prints summary in here mode', async t => { const prompts = { select(opts) {