dependencies.test.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import assert from 'node:assert/strict';
  2. import { dependencies } from '../dist/index.js';
  3. import { describe, it } from 'node:test';
  4. import { setup } from './utils.js';
  5. describe('dependencies', () => {
  6. const fixture = setup();
  7. it('--yes', async () => {
  8. const context = {
  9. cwd: '',
  10. yes: true,
  11. packageManager: 'npm',
  12. dryRun: true,
  13. prompt: () => ({ deps: true }),
  14. };
  15. await dependencies(context);
  16. assert.ok(fixture.hasMessage('Skipping dependency installation'));
  17. });
  18. it('prompt yes', async () => {
  19. const context = {
  20. cwd: '',
  21. packageManager: 'npm',
  22. dryRun: true,
  23. prompt: () => ({ deps: true }),
  24. install: undefined,
  25. };
  26. await dependencies(context);
  27. assert.ok(fixture.hasMessage('Skipping dependency installation'));
  28. assert.equal(context.install, true);
  29. });
  30. it('prompt no', async () => {
  31. const context = {
  32. cwd: '',
  33. install: true,
  34. packageManager: 'npm',
  35. dryRun: true,
  36. prompt: () => ({ deps: false }),
  37. install: undefined,
  38. };
  39. await dependencies(context);
  40. assert.ok(fixture.hasMessage('Skipping dependency installation'));
  41. assert.equal(context.install, false);
  42. });
  43. it('--install', async () => {
  44. const context = {
  45. cwd: '',
  46. install: true,
  47. packageManager: 'npm',
  48. dryRun: true,
  49. prompt: () => ({ deps: false }),
  50. };
  51. await dependencies(context);
  52. assert.ok(fixture.hasMessage('Skipping dependency installation'));
  53. assert.equal(context.install, true);
  54. });
  55. it('--no-install ', async () => {
  56. const context = {
  57. cwd: '',
  58. install: false,
  59. packageManager: 'npm',
  60. dryRun: true,
  61. prompt: () => ({ deps: false }),
  62. };
  63. await dependencies(context);
  64. assert.ok(fixture.hasMessage('Skipping dependency installation'));
  65. assert.equal(context.install, false);
  66. });
  67. });