2023-02-06 16:19:37 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
|
|
|
import { dependencies } from '../dist/index.js';
|
|
|
|
import { setup } from './utils.js';
|
|
|
|
|
|
|
|
describe('dependencies', () => {
|
|
|
|
const fixture = setup();
|
|
|
|
|
|
|
|
it('--yes', async () => {
|
2023-02-06 16:21:48 +00:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
yes: true,
|
2023-09-06 09:15:10 +00:00
|
|
|
packageManager: 'npm',
|
2023-02-06 16:21:48 +00:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: true }),
|
|
|
|
};
|
2023-02-06 16:19:37 +00:00
|
|
|
await dependencies(context);
|
|
|
|
expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
|
2023-02-06 16:21:48 +00:00
|
|
|
});
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
it('prompt yes', async () => {
|
2023-02-06 16:21:48 +00:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
2023-09-06 09:15:10 +00:00
|
|
|
packageManager: 'npm',
|
2023-02-06 16:21:48 +00:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: true }),
|
|
|
|
install: undefined,
|
|
|
|
};
|
2023-02-06 16:19:37 +00:00
|
|
|
await dependencies(context);
|
|
|
|
expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
|
|
|
|
expect(context.install).to.eq(true);
|
2023-02-06 16:21:48 +00:00
|
|
|
});
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
it('prompt no', async () => {
|
2023-02-06 16:21:48 +00:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
2023-09-06 09:15:10 +00:00
|
|
|
packageManager: 'npm',
|
2023-02-06 16:21:48 +00:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
install: undefined,
|
|
|
|
};
|
2023-02-06 16:19:37 +00:00
|
|
|
await dependencies(context);
|
|
|
|
expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
|
|
|
|
expect(context.install).to.eq(false);
|
2023-02-06 16:21:48 +00:00
|
|
|
});
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
it('--install', async () => {
|
2023-02-06 16:21:48 +00:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
install: true,
|
2023-09-06 09:15:10 +00:00
|
|
|
packageManager: 'npm',
|
2023-02-06 16:21:48 +00:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
};
|
2023-02-06 16:19:37 +00:00
|
|
|
await dependencies(context);
|
|
|
|
expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
|
|
|
|
expect(context.install).to.eq(true);
|
2023-02-06 16:21:48 +00:00
|
|
|
});
|
2023-02-06 16:19:37 +00:00
|
|
|
|
|
|
|
it('--no-install', async () => {
|
2023-02-06 16:21:48 +00:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
install: false,
|
2023-09-06 09:15:10 +00:00
|
|
|
packageManager: 'npm',
|
2023-02-06 16:21:48 +00:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
};
|
2023-02-06 16:19:37 +00:00
|
|
|
await dependencies(context);
|
|
|
|
expect(fixture.hasMessage('Skipping dependency installation')).to.be.true;
|
|
|
|
expect(context.install).to.eq(false);
|
2023-02-06 16:21:48 +00:00
|
|
|
});
|
|
|
|
});
|