2024-02-13 09:41:59 -05:00
|
|
|
import assert from 'node:assert/strict';
|
2023-02-06 11:19:37 -05:00
|
|
|
import os from 'node:os';
|
2024-02-13 09:41:59 -05:00
|
|
|
import { describe, it } from 'node:test';
|
2023-02-06 11:19:37 -05:00
|
|
|
import { getContext } from '../dist/index.js';
|
|
|
|
describe('context', () => {
|
|
|
|
it('no arguments', async () => {
|
|
|
|
const ctx = await getContext([]);
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(!ctx.projectName);
|
|
|
|
assert.ok(!ctx.template);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.skipHouston, os.platform() === 'win32');
|
2024-02-13 09:41:59 -05:00
|
|
|
assert.ok(!ctx.dryRun);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('project name', async () => {
|
|
|
|
const ctx = await getContext(['foobar']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.projectName, 'foobar');
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('template', async () => {
|
|
|
|
const ctx = await getContext(['--template', 'minimal']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.template, 'minimal');
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('skip houston (explicit)', async () => {
|
|
|
|
const ctx = await getContext(['--skip-houston']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.skipHouston, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('skip houston (yes)', async () => {
|
|
|
|
const ctx = await getContext(['-y']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.skipHouston, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('skip houston (no)', async () => {
|
|
|
|
const ctx = await getContext(['-n']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.skipHouston, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('skip houston (install)', async () => {
|
|
|
|
const ctx = await getContext(['--install']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.skipHouston, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('dry run', async () => {
|
|
|
|
const ctx = await getContext(['--dry-run']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.dryRun, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('install', async () => {
|
|
|
|
const ctx = await getContext(['--install']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.install, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('no install', async () => {
|
|
|
|
const ctx = await getContext(['--no-install']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.install, false);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('git', async () => {
|
|
|
|
const ctx = await getContext(['--git']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.git, true);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('no git', async () => {
|
|
|
|
const ctx = await getContext(['--no-git']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.git, false);
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
2024-02-13 09:41:59 -05:00
|
|
|
|
2023-02-06 11:19:37 -05:00
|
|
|
it('typescript', async () => {
|
|
|
|
const ctx = await getContext(['--typescript', 'strict']);
|
2024-02-16 06:41:16 -05:00
|
|
|
assert.deepEqual(ctx.typescript, 'strict');
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
|
|
|
});
|