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 { template } from '../dist/index.js';
|
|
|
|
import { setup } from './utils.js';
|
|
|
|
|
2024-02-13 09:41:59 -05:00
|
|
|
describe('template', async () => {
|
2023-02-06 11:19:37 -05:00
|
|
|
const fixture = setup();
|
|
|
|
|
|
|
|
it('none', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = { template: '', cwd: '', dryRun: true, prompt: () => ({ template: 'blog' }) };
|
2023-02-06 11:19:37 -05:00
|
|
|
await template(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Skipping template copying'));
|
|
|
|
assert.equal(context.template, 'blog');
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('minimal (--dry-run)', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = { template: 'minimal', cwd: '', dryRun: true, prompt: () => {} };
|
2023-02-06 11:19:37 -05:00
|
|
|
await template(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Using minimal as project template'));
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('basics (--dry-run)', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = { template: 'basics', cwd: '', dryRun: true, prompt: () => {} };
|
2023-02-06 11:19:37 -05:00
|
|
|
await template(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Using basics as project template'));
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-02-06 11:19:37 -05:00
|
|
|
|
|
|
|
it('blog (--dry-run)', async () => {
|
2023-02-06 11:21:48 -05:00
|
|
|
const context = { template: 'blog', cwd: '', dryRun: true, prompt: () => {} };
|
2023-02-06 11:19:37 -05:00
|
|
|
await template(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Using blog as project template'));
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2023-09-22 08:18:46 -05:00
|
|
|
|
2023-09-22 08:20:50 -05:00
|
|
|
it('minimal (--yes)', async () => {
|
|
|
|
const context = { template: 'minimal', cwd: '', dryRun: true, yes: true, prompt: () => {} };
|
|
|
|
await template(context);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(fixture.hasMessage('Using minimal as project template'));
|
2023-09-22 08:20:50 -05:00
|
|
|
});
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|