diff options
Diffstat (limited to 'packages/astro')
-rw-r--r-- | packages/astro/src/compiler/codegen/content.ts | 7 | ||||
-rw-r--r-- | packages/astro/test/astro-basic.test.js | 2 | ||||
-rw-r--r-- | packages/astro/test/astro-children.test.js | 6 | ||||
-rw-r--r-- | packages/astro/test/astro-collection.test.js | 2 | ||||
-rw-r--r-- | packages/astro/test/astro-css-bundling.test.js | 10 | ||||
-rw-r--r-- | packages/astro/test/astro-doctype.test.js | 6 | ||||
-rw-r--r-- | packages/astro/test/astro-dynamic.test.js | 3 | ||||
-rw-r--r-- | packages/astro/test/astro-expr.test.js | 12 | ||||
-rw-r--r-- | packages/astro/test/astro-fallback.test.js | 3 | ||||
-rw-r--r-- | packages/astro/test/astro-global.test.js | 6 | ||||
-rw-r--r-- | packages/astro/test/astro-markdown.test.js | 4 | ||||
-rw-r--r-- | packages/astro/test/react-component.test.js | 6 |
12 files changed, 28 insertions, 39 deletions
diff --git a/packages/astro/src/compiler/codegen/content.ts b/packages/astro/src/compiler/codegen/content.ts index 4c542671b..1b630c912 100644 --- a/packages/astro/src/compiler/codegen/content.ts +++ b/packages/astro/src/compiler/codegen/content.ts @@ -42,14 +42,11 @@ function globSearch(spec: string, { filename }: { filename: string }): string[] } const cwd = path.join(path.dirname(filename), globDir.replace(/\//g, path.sep)); // this must match OS (could be '/' or '\') - let found = crawler - .glob(glob) - .crawlWithOptions(cwd, { includeBasePath: true }) - .sync() as PathsOutput; + let found = crawler.glob(glob).crawlWithOptions(cwd, { includeBasePath: true }).sync() as PathsOutput; if (!found.length) { throw new Error(`No files matched "${spec}" from ${filename}`); } - return found.map(importPath => { + return found.map((importPath) => { if (importPath.startsWith('http') || importPath.startsWith('.')) return importPath; return './' + path.posix.join(globDir, path.posix.relative(slash(cwd), importPath)); }); diff --git a/packages/astro/test/astro-basic.test.js b/packages/astro/test/astro-basic.test.js index 89dcf3553..ce9f1cded 100644 --- a/packages/astro/test/astro-basic.test.js +++ b/packages/astro/test/astro-basic.test.js @@ -9,8 +9,8 @@ setup(Basics, './fixtures/astro-basic'); Basics('Can load page', async ({ runtime }) => { const result = await runtime.load('/'); + if (result.error) throw new Error(result.error); - assert.equal(result.statusCode, 200); const $ = doc(result.contents); assert.equal($('h1').text(), 'Hello world!'); diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.test.js index 368cfc9f9..f44e1f377 100644 --- a/packages/astro/test/astro-children.test.js +++ b/packages/astro/test/astro-children.test.js @@ -10,8 +10,8 @@ setupBuild(ComponentChildren, './fixtures/astro-children'); ComponentChildren('Passes string children to framework components', async ({ runtime }) => { let result = await runtime.load('/strings'); + if (result.error) throw new Error(result.error); - assert.equal(result.statusCode, 200); const $ = doc(result.contents); const $preact = $('#preact'); @@ -26,8 +26,8 @@ ComponentChildren('Passes string children to framework components', async ({ run ComponentChildren('Passes markup children to framework components', async ({ runtime }) => { let result = await runtime.load('/markup'); + if (result.error) throw new Error(result.error); - assert.equal(result.statusCode, 200); const $ = doc(result.contents); const $preact = $('#preact > h1'); @@ -42,8 +42,8 @@ ComponentChildren('Passes markup children to framework components', async ({ run ComponentChildren('Passes multiple children to framework components', async ({ runtime }) => { let result = await runtime.load('/multiple'); + if (result.error) throw new Error(result.error); - assert.equal(result.statusCode, 200); const $ = doc(result.contents); const $preact = $('#preact'); diff --git a/packages/astro/test/astro-collection.test.js b/packages/astro/test/astro-collection.test.js index 72d4f2314..e424d3871 100644 --- a/packages/astro/test/astro-collection.test.js +++ b/packages/astro/test/astro-collection.test.js @@ -9,6 +9,7 @@ setup(Collections, './fixtures/astro-collection'); Collections('generates list & sorts successfully', async ({ runtime }) => { const result = await runtime.load('/posts'); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); const urls = [ ...$('#posts a').map(function () { @@ -20,6 +21,7 @@ Collections('generates list & sorts successfully', async ({ runtime }) => { Collections('generates pagination successfully', async ({ runtime }) => { const result = await runtime.load('/posts'); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); const prev = $('#prev-page'); const next = $('#next-page'); diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js index fe8d82c98..7b00c233c 100644 --- a/packages/astro/test/astro-css-bundling.test.js +++ b/packages/astro/test/astro-css-bundling.test.js @@ -10,9 +10,9 @@ setupBuild(CSSBundling, './fixtures/astro-css-bundling'); // note: the hashes should be deterministic, but updating the file contents will change hashes // be careful not to test that the HTML simply contains CSS, because it always will! filename and quanity matter here (bundling). const EXPECTED_CSS = { - '/index.html': ['/_astro/common-ZVuUT3.css', '/_astro/index-Z2jH7pc.css'], - '/one/index.html': ['/_astro/common-ZVuUT3.css', '/_astro/one/index-2qFtfN.css'], - '/two/index.html': ['/_astro/common-ZVuUT3.css', '/_astro/two/index-2jKE68.css'], + '/index.html': ['/_astro/common-', '/_astro/index-'], // don’t match hashes, which change based on content + '/one/index.html': ['/_astro/common-', '/_astro/one/index-'], + '/two/index.html': ['/_astro/common-', '/_astro/two/index-'], }; const UNEXPECTED_CSS = ['/_astro/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css']; @@ -28,9 +28,9 @@ CSSBundling('Bundles CSS', async (context) => { // test 1: assert new bundled CSS is present for (const href of css) { - builtCSS.add(href); - const link = $(`link[href="${href}"]`); + const link = $(`link[href^="${href}"]`); assert.equal(link.length, 1); + builtCSS.add(link.attr('href')); } // test 2: assert old CSS was removed diff --git a/packages/astro/test/astro-doctype.test.js b/packages/astro/test/astro-doctype.test.js index c1b94908b..d0d0db105 100644 --- a/packages/astro/test/astro-doctype.test.js +++ b/packages/astro/test/astro-doctype.test.js @@ -34,8 +34,7 @@ DType('No errors creating a runtime', () => { DType('Automatically prepends the standards mode doctype', async () => { const result = await runtime.load('/prepend'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const html = result.contents.toString('utf-8'); assert.ok(html.startsWith('<!doctype html>'), 'Doctype always included'); @@ -43,8 +42,7 @@ DType('Automatically prepends the standards mode doctype', async () => { DType.skip('Preserves user provided doctype', async () => { const result = await runtime.load('/preserve'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const html = result.contents.toString('utf-8'); assert.ok(html.startsWith('<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'), 'Doctype included was preserved'); diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js index 0bf25df8a..8ef6895f6 100644 --- a/packages/astro/test/astro-dynamic.test.js +++ b/packages/astro/test/astro-dynamic.test.js @@ -9,8 +9,7 @@ setupBuild(DynamicComponents, './fixtures/astro-dynamic'); DynamicComponents('Loads client-only packages', async ({ runtime }) => { let result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); // Grab the react-dom import const exp = /import\("(.+?)"\)/g; diff --git a/packages/astro/test/astro-expr.test.js b/packages/astro/test/astro-expr.test.js index c3c985712..c424c3863 100644 --- a/packages/astro/test/astro-expr.test.js +++ b/packages/astro/test/astro-expr.test.js @@ -9,8 +9,7 @@ setup(Expressions, './fixtures/astro-expr'); Expressions('Can load page', async ({ runtime }) => { const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); @@ -21,8 +20,7 @@ Expressions('Can load page', async ({ runtime }) => { Expressions('Ignores characters inside of strings', async ({ runtime }) => { const result = await runtime.load('/strings'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); @@ -33,7 +31,7 @@ Expressions('Ignores characters inside of strings', async ({ runtime }) => { Expressions('Ignores characters inside of line comments', async ({ runtime }) => { const result = await runtime.load('/line-comments'); - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); @@ -44,7 +42,7 @@ Expressions('Ignores characters inside of line comments', async ({ runtime }) => Expressions('Ignores characters inside of multiline comments', async ({ runtime }) => { const result = await runtime.load('/multiline-comments'); - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); @@ -55,7 +53,7 @@ Expressions('Ignores characters inside of multiline comments', async ({ runtime Expressions('Allows multiple JSX children in mustache', async ({ runtime }) => { const result = await runtime.load('/multiple-children'); - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); assert.ok(result.contents.includes('#f') && !result.contents.includes('#t')); }); diff --git a/packages/astro/test/astro-fallback.test.js b/packages/astro/test/astro-fallback.test.js index 2acf29f8e..a4edec371 100644 --- a/packages/astro/test/astro-fallback.test.js +++ b/packages/astro/test/astro-fallback.test.js @@ -9,8 +9,7 @@ setup(Fallback, './fixtures/astro-fallback'); Fallback('Shows static content', async (context) => { const result = await context.runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.equal($('#fallback').text(), 'static'); diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js index 891e1cfb2..5ea5c46f9 100644 --- a/packages/astro/test/astro-global.test.js +++ b/packages/astro/test/astro-global.test.js @@ -9,8 +9,7 @@ setup(Global, './fixtures/astro-global'); Global('Astro.request.url', async (context) => { const result = await context.runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.equal($('#pathname').text(), '/'); @@ -35,8 +34,7 @@ Global('Astro.request.canonicalURL', async (context) => { Global('Astro.site', async (context) => { const result = await context.runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.equal($('#site').attr('href'), 'https://mysite.dev'); diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index ba0197e5f..8c467bf9d 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -43,8 +43,7 @@ Markdown('No errors creating a runtime', () => { Markdown('Can load markdown pages with hmx', async () => { const result = await runtime.load('/post'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.ok($('#first').length, 'There is a div added in markdown'); @@ -53,6 +52,7 @@ Markdown('Can load markdown pages with hmx', async () => { Markdown('Can load more complex jsxy stuff', async () => { const result = await runtime.load('/complex'); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); const $el = $('#test'); diff --git a/packages/astro/test/react-component.test.js b/packages/astro/test/react-component.test.js index d7442bc98..10b44120c 100644 --- a/packages/astro/test/react-component.test.js +++ b/packages/astro/test/react-component.test.js @@ -35,8 +35,7 @@ React('No error creating the runtime', () => { React('Can load React', async () => { const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.equal($('#react-h2').text(), 'Hello world!'); @@ -44,8 +43,7 @@ React('Can load React', async () => { React('Can load Vue', async () => { const result = await runtime.load('/'); - - assert.equal(result.statusCode, 200); + if (result.error) throw new Error(result.error); const $ = doc(result.contents); assert.equal($('#vue-h2').text(), 'Hasta la vista, baby'); |