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 16, 2022
1 parent 3c2f069 commit 5a69415
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
40 changes: 20 additions & 20 deletions packages/cli/tests/images/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ exports.default = {
'assets/icons/mstile-150x150.png': 9050,
'assets/favicon.ico': 15086,

'ssr-build/ssr-bundle.77c49.css': 1281,
'ssr-build/ssr-bundle.77c49.css.map': 2070,
'ssr-build/ssr-bundle.c9123.css': 1281,
'ssr-build/ssr-bundle.c9123.css.map': 2070,
'ssr-build/ssr-bundle.js': 9801,
'ssr-build/ssr-bundle.js.map': 30625,
'ssr-build/asset-manifest.json': 82,

'bundle.6d2a5.js': 21323,
'bundle.6d2a5.js.map': 85534,
'bundle.6d2a5.legacy.js': 22514,
'bundle.6d2a5.legacy.js.map': 106422,
'bundle.9bde9.css': 945,
'bundle.9bde9.css.map': 1758,
'bundle.923ca.js': 21323,
'bundle.923ca.js.map': 85534,
'bundle.923ca.legacy.js': 22514,
'bundle.923ca.legacy.js.map': 106422,
'bundle.a2557.css': 945,
'bundle.a2557.css.map': 1758,

'dom-polyfills.c88f4.legacy.js': 5252,
'dom-polyfills.c88f4.legacy.js.map': 18836,
Expand All @@ -31,19 +31,19 @@ exports.default = {
'push-manifest.json': 450,
'asset-manifest.json': 943,

'route-home.chunk.25907.js': 306,
'route-home.chunk.25907.js.map': 1615,
'route-home.chunk.25907.legacy.js': 363,
'route-home.chunk.25907.legacy.js.map': 1913,
'route-home.chunk.f1c94.css': 112,
'route-home.chunk.f1c94.css.map': 224,
'route-home.chunk.43403.js': 306,
'route-home.chunk.43403.js.map': 1615,
'route-home.chunk.43403.legacy.js': 363,
'route-home.chunk.43403.legacy.js.map': 1913,
'route-home.chunk.6eaee.css': 112,
'route-home.chunk.6eaee.css.map': 224,

'route-profile.chunk.d1e1a.js': 2469,
'route-profile.chunk.d1e1a.js.map': 9736,
'route-profile.chunk.d1e1a.legacy.js': 2624,
'route-profile.chunk.d1e1a.legacy.js.map': 12373,
'route-profile.chunk.e0d39.css': 118,
'route-profile.chunk.e0d39.css.map': 231,
'route-profile.chunk.dfd89.js': 2469,
'route-profile.chunk.dfd89.js.map': 9736,
'route-profile.chunk.dfd89.legacy.js': 2624,
'route-profile.chunk.dfd89.legacy.js.map': 12373,
'route-profile.chunk.0af3e.css': 118,
'route-profile.chunk.0af3e.css.map': 231,
};

exports.sass = `
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 += '#main';
}
}

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);
});
});
6 changes: 3 additions & 3 deletions packages/create-cli/tests/images/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ exports.default = [
'src/assets/icons/mstile-150x150.png',
'src/components/app.js',
'src/components/header/index.js',
'src/components/header/style.css',
'src/components/header/style.module.css',
'src/index.js',
'src/manifest.json',
'src/routes/home/index.js',
'src/routes/home/style.css',
'src/routes/home/style.module.css',
'src/routes/profile/index.js',
'src/routes/profile/style.css',
'src/routes/profile/style.module.css',
'src/style/index.css',
'src/sw.js',
'src/template.html',
Expand Down

0 comments on commit 5a69415

Please sign in to comment.