Skip to content

Commit

Permalink
Added tests for print summary after installation with npm and `pnpm…
Browse files Browse the repository at this point in the history
…`, in addition to `yarn`
  • Loading branch information
nenadvicentic committed Sep 28, 2022
1 parent 840ef71 commit ee05aee
Showing 1 changed file with 80 additions and 2 deletions.
82 changes: 80 additions & 2 deletions __test__/after-task.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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';
}
};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ee05aee

Please sign in to comment.