template.test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import assert from 'node:assert/strict';
  2. import { describe, it } from 'node:test';
  3. import { template } from '../dist/index.js';
  4. import { setup } from './utils.js';
  5. describe('template', async () => {
  6. const fixture = setup();
  7. it('none', async () => {
  8. const context = { template: '', cwd: '', dryRun: true, prompt: () => ({ template: 'blog' }) };
  9. await template(context);
  10. assert.ok(fixture.hasMessage('Skipping template copying'));
  11. assert.equal(context.template, 'blog');
  12. });
  13. it('minimal (--dry-run)', async () => {
  14. const context = { template: 'minimal', cwd: '', dryRun: true, prompt: () => {} };
  15. await template(context);
  16. assert.ok(fixture.hasMessage('Using minimal as project template'));
  17. });
  18. it('basics (--dry-run)', async () => {
  19. const context = { template: 'basics', cwd: '', dryRun: true, prompt: () => {} };
  20. await template(context);
  21. assert.ok(fixture.hasMessage('Using basics as project template'));
  22. });
  23. it('blog (--dry-run)', async () => {
  24. const context = { template: 'blog', cwd: '', dryRun: true, prompt: () => {} };
  25. await template(context);
  26. assert.ok(fixture.hasMessage('Using blog as project template'));
  27. });
  28. it('minimal (--yes)', async () => {
  29. const context = { template: 'minimal', cwd: '', dryRun: true, yes: true, prompt: () => {} };
  30. await template(context);
  31. assert.ok(fixture.hasMessage('Using minimal as project template'));
  32. });
  33. });