context.test.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import assert from 'node:assert/strict';
  2. import { describe, it } from 'node:test';
  3. import os from 'node:os';
  4. import { getContext } from '../dist/index.js';
  5. describe('context', () => {
  6. it('no arguments', async () => {
  7. const ctx = await getContext([]);
  8. assert.ok(!ctx.projectName);
  9. assert.ok(!ctx.template);
  10. assert.deepEqual(ctx.skipHouston, os.platform() === 'win32');
  11. assert.ok(!ctx.dryRun);
  12. });
  13. it('project name', async () => {
  14. const ctx = await getContext(['foobar']);
  15. assert.deepEqual(ctx.projectName, 'foobar');
  16. });
  17. it('template', async () => {
  18. const ctx = await getContext(['--template', 'minimal']);
  19. assert.deepEqual(ctx.template, 'minimal');
  20. });
  21. it('skip houston (explicit)', async () => {
  22. const ctx = await getContext(['--skip-houston']);
  23. assert.deepEqual(ctx.skipHouston, true);
  24. });
  25. it('skip houston (yes)', async () => {
  26. const ctx = await getContext(['-y']);
  27. assert.deepEqual(ctx.skipHouston, true);
  28. });
  29. it('skip houston (no)', async () => {
  30. const ctx = await getContext(['-n']);
  31. assert.deepEqual(ctx.skipHouston, true);
  32. });
  33. it('skip houston (install)', async () => {
  34. const ctx = await getContext(['--install']);
  35. assert.deepEqual(ctx.skipHouston, true);
  36. });
  37. it('dry run', async () => {
  38. const ctx = await getContext(['--dry-run']);
  39. assert.deepEqual(ctx.dryRun, true);
  40. });
  41. it('install', async () => {
  42. const ctx = await getContext(['--install']);
  43. assert.deepEqual(ctx.install, true);
  44. });
  45. it('no install', async () => {
  46. const ctx = await getContext(['--no-install']);
  47. assert.deepEqual(ctx.install, false);
  48. });
  49. it('git', async () => {
  50. const ctx = await getContext(['--git']);
  51. assert.deepEqual(ctx.git, true);
  52. });
  53. it('no git', async () => {
  54. const ctx = await getContext(['--no-git']);
  55. assert.deepEqual(ctx.git, false);
  56. });
  57. it('typescript', async () => {
  58. const ctx = await getContext(['--typescript', 'strict']);
  59. assert.deepEqual(ctx.typescript, 'strict');
  60. });
  61. });