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 7f85c2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
24 changes: 12 additions & 12 deletions packages/cli/tests/images/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ exports.default = {
'ssr-build/ssr-bundle.js.map': 30625,
'ssr-build/asset-manifest.json': 82,

'bundle.3f496.js': 21323,
'bundle.3f496.js.map': 85534,
'bundle.3f496.legacy.js': 22514,
'bundle.3f496.legacy.js.map': 106422,
'bundle.86ff2.js': 21323,
'bundle.86ff2.js.map': 85534,
'bundle.86ff2.legacy.js': 22514,
'bundle.86ff2.legacy.js.map': 106422,
'bundle.a2557.css': 945,
'bundle.a2557.css.map': 1758,

Expand All @@ -31,17 +31,17 @@ exports.default = {
'push-manifest.json': 450,
'asset-manifest.json': 943,

'route-home.chunk.b9f12.js': 306,
'route-home.chunk.b9f12.js.map': 1615,
'route-home.chunk.b9f12.legacy.js': 363,
'route-home.chunk.b9f12.legacy.js.map': 1913,
'route-home.chunk.b77d6.js': 306,
'route-home.chunk.b77d6.js.map': 1490,
'route-home.chunk.b77d6.legacy.js': 363,
'route-home.chunk.b77d6.legacy.js.map': 1752,
'route-home.chunk.6eaee.css': 112,
'route-home.chunk.6eaee.css.map': 224,

'route-profile.chunk.d94b1.js': 2469,
'route-profile.chunk.d94b1.js.map': 9736,
'route-profile.chunk.d94b1.legacy.js': 2624,
'route-profile.chunk.d94b1.legacy.js.map': 12373,
'route-profile.chunk.d8eb4.js': 2469,
'route-profile.chunk.d8eb4.js.map': 9736,
'route-profile.chunk.d8eb4.legacy.js': 2624,
'route-profile.chunk.d8eb4.legacy.js.map': 12373,
'route-profile.chunk.0af3e.css': 118,
'route-profile.chunk.0af3e.css.map': 231,
};
Expand Down
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 7f85c2d

Please sign in to comment.