0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/create-astro/test/context.test.js
Shoaib Khan 3007d24c98
chore: Migrate all packages/create-astro/test to node:test (#10084)
* chore: Migrate All packages/create-astro/test to node:test

* Some minor fix

* Requested Changes done

* Reopen

* Apply suggestions from code review

* let's test with concurrency

* chore: fix possible false positive tests

* todo test

* skip tests

* Apply suggestions from code review

---------

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
2024-02-13 14:41:59 +00:00

73 lines
2 KiB
JavaScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import os from 'node:os';
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.deepStrictEqual(ctx.skipHouston, os.platform() === 'win32');
assert.ok(!ctx.dryRun);
});
it('project name', async () => {
const ctx = await getContext(['foobar']);
assert.deepStrictEqual(ctx.projectName, 'foobar');
});
it('template', async () => {
const ctx = await getContext(['--template', 'minimal']);
assert.deepStrictEqual(ctx.template, 'minimal');
});
it('skip houston (explicit)', async () => {
const ctx = await getContext(['--skip-houston']);
assert.deepStrictEqual(ctx.skipHouston, true);
});
it('skip houston (yes)', async () => {
const ctx = await getContext(['-y']);
assert.deepStrictEqual(ctx.skipHouston, true);
});
it('skip houston (no)', async () => {
const ctx = await getContext(['-n']);
assert.deepStrictEqual(ctx.skipHouston, true);
});
it('skip houston (install)', async () => {
const ctx = await getContext(['--install']);
assert.deepStrictEqual(ctx.skipHouston, true);
});
it('dry run', async () => {
const ctx = await getContext(['--dry-run']);
assert.deepStrictEqual(ctx.dryRun, true);
});
it('install', async () => {
const ctx = await getContext(['--install']);
assert.deepStrictEqual(ctx.install, true);
});
it('no install', async () => {
const ctx = await getContext(['--no-install']);
assert.deepStrictEqual(ctx.install, false);
});
it('git', async () => {
const ctx = await getContext(['--git']);
assert.deepStrictEqual(ctx.git, true);
});
it('no git', async () => {
const ctx = await getContext(['--no-git']);
assert.deepStrictEqual(ctx.git, false);
});
it('typescript', async () => {
const ctx = await getContext(['--typescript', 'strict']);
assert.deepStrictEqual(ctx.typescript, 'strict');
});
});