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/create-astro.test.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import execa from 'execa';
import del from 'del';
import * as assert from 'uvu/assert';
const CreateAstro = suite('npm init astro');
const cwd = fileURLToPath(new URL('./fixtures/', import.meta.url));
const templates = ['blank', 'starter'];
CreateAstro.before(async () => {
await del(cwd);
await fs.promises.mkdir(cwd);
});
for (const template of templates) {
CreateAstro(template, async () => {
await execa('../../create-astro.js', [template, '--template', template], { cwd });
const DOES_HAVE = ['.gitignore', 'package.json', 'public', 'src'];
const DOES_NOT_HAVE = ['_gitignore', 'meta.json'];
// test: template contains essential files & folders
for (const file of DOES_HAVE) {
assert.ok(fs.existsSync(path.join(cwd, template, file)), `has ${file}`);
}
// test: template DOES NOT contain files supposed to be stripped away
for (const file of DOES_NOT_HAVE) {
assert.not.ok(fs.existsSync(path.join(cwd, template, `does not have ${file}`)));
}
});
}
CreateAstro.run();