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