astro/packages/create-astro/test/context.test.js
Nate Moore 8d2187d8b8
Refactor create-astro (#6082)
* refactor: new version of create-astro

* chore: update README

* fix(create-astro): update project name logic

* test(create-astro): fix test on windows

* test(create-astro): fix test on windows

* test(create-astro): remove unused import

* chore: remove log

* chore: increase test timeout

* fix: message when skipping

* fix: message for env.d.ts file

* fix: always hard exit

* fix: return from next-steps

* chore: add message

* refactor dependencies, bundle create-astro

* chore: disable create-astro typings

* chore: switch to arg

* chore: update message

* fix: split typescript into two steps, fix context test

* chore: update wording

* chore: update wording

* Update packages/create-astro/src/actions/dependencies.ts

Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>

* refactor: move tests back to mocha/chai

* chore: update cli-kit

* update test script

* chore: add comment about setStdout

* chore: update cli-kit

* Update packages/create-astro/src/messages.ts

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update packages/create-astro/src/messages.ts

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* chore: update lockfile

* fix(create-astro): support scoped package names, improve project-name tests

* better git initialization

* update cli-kit

---------

Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-02-06 10:19:37 -06:00

62 lines
1.8 KiB
JavaScript

import { expect } from 'chai';
import os from 'node:os';
import { getContext } from '../dist/index.js';
describe('context', () => {
it('no arguments', async () => {
const ctx = await getContext([]);
expect(ctx.projectName).to.be.undefined;
expect(ctx.template).to.be.undefined;
expect(ctx.skipHouston).to.eq(os.platform() === 'win32');
expect(ctx.dryRun).to.be.undefined;
})
it('project name', async () => {
const ctx = await getContext(['foobar']);
expect(ctx.projectName).to.eq('foobar');
})
it('template', async () => {
const ctx = await getContext(['--template', 'minimal']);
expect(ctx.template).to.eq('minimal');
})
it('skip houston (explicit)', async () => {
const ctx = await getContext(['--skip-houston']);
expect(ctx.skipHouston).to.eq(true);
})
it('skip houston (yes)', async () => {
const ctx = await getContext(['-y']);
expect(ctx.skipHouston).to.eq(true);
})
it('skip houston (no)', async () => {
const ctx = await getContext(['-n']);
expect(ctx.skipHouston).to.eq(true);
})
it('skip houston (install)', async () => {
const ctx = await getContext(['--install']);
expect(ctx.skipHouston).to.eq(true);
})
it('dry run', async () => {
const ctx = await getContext(['--dry-run']);
expect(ctx.dryRun).to.eq(true);
})
it('install', async () => {
const ctx = await getContext(['--install']);
expect(ctx.install).to.eq(true);
})
it('no install', async () => {
const ctx = await getContext(['--no-install']);
expect(ctx.install).to.eq(false);
})
it('git', async () => {
const ctx = await getContext(['--git']);
expect(ctx.git).to.eq(true);
})
it('no git', async () => {
const ctx = await getContext(['--no-git']);
expect(ctx.git).to.eq(false);
})
it('typescript', async () => {
const ctx = await getContext(['--typescript', 'strict']);
expect(ctx.typescript).to.eq('strict');
})
})