2024-02-13 09:41:59 -05:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { describe, it } from 'node:test';
|
2023-02-06 11:19:37 -05:00
|
|
|
import { dependencies } from '../dist/index.js';
|
|
|
|
import { setup } from './utils.js';
|
|
|
|
describe('dependencies', () => {
|
|
|
|
const fixture = setup();
|
|
|
|
|
|
|
|
it('--yes', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
yes: true,
|
2023-09-06 04:15:10 -05:00
|
|
|
packageManager: 'npm',
|
2023-02-06 11:21:48 -05:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: true }),
|
|
|
|
};
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
await dependencies(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
|
|
|
|
assert.ok(fixture.hasMessage('Skipping dependency installation'));
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('prompt yes', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
2023-09-06 04:15:10 -05:00
|
|
|
packageManager: 'npm',
|
2023-02-06 11:21:48 -05:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: true }),
|
|
|
|
install: undefined,
|
|
|
|
};
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
await dependencies(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
|
|
|
|
assert.ok(fixture.hasMessage('Skipping dependency installation'));
|
|
|
|
assert.equal(context.install, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('prompt no', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
2024-02-13 09:41:59 -05:00
|
|
|
install: true,
|
2023-09-06 04:15:10 -05:00
|
|
|
packageManager: 'npm',
|
2023-02-06 11:21:48 -05:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
install: undefined,
|
|
|
|
};
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
await dependencies(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
|
|
|
|
assert.ok(fixture.hasMessage('Skipping dependency installation'));
|
|
|
|
assert.equal(context.install, false);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('--install', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
install: true,
|
2023-09-06 04:15:10 -05:00
|
|
|
packageManager: 'npm',
|
2023-02-06 11:21:48 -05:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
};
|
2023-02-06 11:19:37 -05:00
|
|
|
await dependencies(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Skipping dependency installation'));
|
|
|
|
assert.equal(context.install, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
2024-02-13 09:41:59 -05:00
|
|
|
it('--no-install ', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
install: false,
|
2023-09-06 04:15:10 -05:00
|
|
|
packageManager: 'npm',
|
2023-02-06 11:21:48 -05:00
|
|
|
dryRun: true,
|
|
|
|
prompt: () => ({ deps: false }),
|
|
|
|
};
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
await dependencies(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
|
|
|
|
assert.ok(fixture.hasMessage('Skipping dependency installation'));
|
|
|
|
assert.equal(context.install, false);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
|
|
|
});
|