Skip to content

Commit

Permalink
test: Update 'create' test suite & build output hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Jul 25, 2022
1 parent e0c4de0 commit 80364d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
11 changes: 5 additions & 6 deletions packages/create-cli/src/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ exports.create = async function create(repo, dest, argv) {

if (!repo.includes('/')) {
repo = `preactjs-templates/${repo}`;

// TODO: Remove this after updating all templates
if (repo.endsWith('default') || repo.endsWith('typescript')) {
repo += '#next';
}
}

await mkdir(resolve(cwd, dest), { recursive: true });
Expand Down Expand Up @@ -109,12 +114,6 @@ exports.create = async function create(repo, dest, argv) {
await copyTemplateFile(serviceWorkerSrc, serviceWorkerDest, argv.force);
}

// TODO: Remove when templates are updated
const packagePath = join(target, 'package.json');
let packageFile = JSON.parse(await readFile(packagePath, 'utf-8'));
packageFile.name = 'foo';
await writeFile(packagePath, JSON.stringify(packageFile, null, 2));

if (argv.install) {
spinner.text = 'installing dependencies...';
spinner.stopAndPersist();
Expand Down
13 changes: 2 additions & 11 deletions packages/create-cli/tests/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { expand } = require('../../cli/tests/lib/utils');
const snapshots = require('./images/create');

describe('preact create', () => {
it(`scaffolds the 'default' official template`, async () => {
it('scaffolds the `default` official template', async () => {
let dir = await create('default');

let output = await expand(dir).then(arr => {
Expand All @@ -15,21 +15,12 @@ describe('preact create', () => {
expect(output.sort()).toEqual(snapshots.default);
});

it(`should use template.html from the github repo`, async () => {
it('should use template.html from the repo if one exists', async () => {
let dir = await create('netlify');

const templateFilePath = resolve(__dirname, dir, 'src', 'template.html');
const template = await readFile(templateFilePath, 'utf8');

expect(template.includes('twitter:card')).toEqual(true);
});

it(`should have 'apple-touch-icon' meta tag`, async () => {
let dir = await create('simple');

const templateFilePath = resolve(__dirname, dir, 'src', 'template.html');
const template = await readFile(templateFilePath, 'utf8');

expect(template.includes('apple-touch-icon')).toEqual(true);
});
});

0 comments on commit 80364d4

Please sign in to comment.