summaryrefslogtreecommitdiff
path: root/packages/create-astro/test/context.test.js
blob: b4e67a8c69bbe9788bb62c217a79cab39cab4e44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import assert from 'node:assert/strict';
import os from 'node:os';
import { describe, it } from 'node:test';
import { getContext } from '../dist/index.js';
describe('context', () => {
	it('no arguments', async () => {
		const ctx = await getContext([]);
		assert.ok(!ctx.projectName);
		assert.ok(!ctx.template);
		assert.deepEqual(ctx.skipHouston, os.platform() === 'win32');
		assert.ok(!ctx.dryRun);
	});

	it('project name', async () => {
		const ctx = await getContext(['foobar']);
		assert.deepEqual(ctx.projectName, 'foobar');
	});

	it('template', async () => {
		const ctx = await getContext(['--template', 'minimal']);
		assert.deepEqual(ctx.template, 'minimal');
	});

	it('skip houston (explicit)', async () => {
		const ctx = await getContext(['--skip-houston']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (yes)', async () => {
		const ctx = await getContext(['-y']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (no)', async () => {
		const ctx = await getContext(['-n']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('skip houston (install)', async () => {
		const ctx = await getContext(['--install']);
		assert.deepEqual(ctx.skipHouston, true);
	});

	it('dry run', async () => {
		const ctx = await getContext(['--dry-run']);
		assert.deepEqual(ctx.dryRun, true);
	});

	it('install', async () => {
		const ctx = await getContext(['--install']);
		assert.deepEqual(ctx.install, true);
	});

	it('add', async () => {
		const ctx = await getContext(['--add', 'node']);
		assert.deepEqual(ctx.add, ['node']);
	});

	it('no install', async () => {
		const ctx = await getContext(['--no-install']);
		assert.deepEqual(ctx.install, false);
	});

	it('git', async () => {
		const ctx = await getContext(['--git']);
		assert.deepEqual(ctx.git, true);
	});

	it('no git', async () => {
		const ctx = await getContext(['--no-git']);
		assert.deepEqual(ctx.git, false);
	});
});