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 os from 'node:os';
|
|
|
|
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);
|
|
|
|
assert.deepStrictEqual(ctx.skipHouston, os.platform() === 'win32');
|
|
|
|
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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(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-13 09:41:59 -05:00
|
|
|
assert.deepStrictEqual(ctx.typescript, 'strict');
|
2023-02-06 11:21:48 -05:00
|
|
|
});
|
|
|
|
});
|