From 48bde7018e6b6a265a80e7aa282daf6e8ea607be Mon Sep 17 00:00:00 2001 From: matthewp Date: Tue, 8 Nov 2022 22:31:47 +0000 Subject: [PATCH] [ci] format --- .../astro/src/core/routing/manifest/create.ts | 2 +- .../src/vite-plugin-load-fallback/index.ts | 2 +- packages/astro/test/units/dev/dev.test.js | 74 ++++++++++--------- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 4e1fddb7d..4efe4f8cf 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -355,7 +355,7 @@ export function createRouteManifest( let resolved: string; try { resolved = require.resolve(entryPoint, { paths: [cwd || fileURLToPath(config.root)] }); - } catch(e) { + } catch (e) { resolved = fileURLToPath(new URL(entryPoint, config.root)); } const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved)); diff --git a/packages/astro/src/vite-plugin-load-fallback/index.ts b/packages/astro/src/vite-plugin-load-fallback/index.ts index 7bfe4224a..eaff71bfc 100644 --- a/packages/astro/src/vite-plugin-load-fallback/index.ts +++ b/packages/astro/src/vite-plugin-load-fallback/index.ts @@ -47,7 +47,7 @@ export default function loadFallbackPlugin({ return npath.posix.join(npath.posix.dirname(parent), id); } else { let resolved = await this.resolve(id, parent, { skipSelf: true }); - if(resolved) { + if (resolved) { return resolved.id; } return slashify(id); diff --git a/packages/astro/test/units/dev/dev.test.js b/packages/astro/test/units/dev/dev.test.js index d19f7971f..88fbaac45 100644 --- a/packages/astro/test/units/dev/dev.test.js +++ b/packages/astro/test/units/dev/dev.test.js @@ -108,47 +108,53 @@ describe('dev container', () => { }); it('Allows dynamic segments in injected routes', async () => { - const fs = createFs({ + const fs = createFs( + { '/src/components/test.astro': `

{Astro.params.slug}

`, '/src/pages/test-[slug].astro': `

{Astro.params.slug}

`, }, root ); - await runInContainer({ - fs, - root, - userConfig: { - output: 'server', - integrations: [{ - name: '@astrojs/test-integration', - hooks: { - 'astro:config:setup': ({ injectRoute }) => { - injectRoute({ - pattern: '/another-[slug]', - entryPoint: './src/components/test.astro', - }); + await runInContainer( + { + fs, + root, + userConfig: { + output: 'server', + integrations: [ + { + name: '@astrojs/test-integration', + hooks: { + 'astro:config:setup': ({ injectRoute }) => { + injectRoute({ + pattern: '/another-[slug]', + entryPoint: './src/components/test.astro', + }); + }, + }, }, - }, - }] - } - }, async (container) => { - let r = createRequestAndResponse({ - method: 'GET', - url: '/test-one', - }); - container.handle(r.req, r.res); - await r.done; - expect(r.res.statusCode).to.equal(200); + ], + }, + }, + async (container) => { + let r = createRequestAndResponse({ + method: 'GET', + url: '/test-one', + }); + container.handle(r.req, r.res); + await r.done; + expect(r.res.statusCode).to.equal(200); - // Try with the injected route - r = createRequestAndResponse({ - method: 'GET', - url: '/another-two', - }); - container.handle(r.req, r.res); - await r.done; - expect(r.res.statusCode).to.equal(200); - }); + // Try with the injected route + r = createRequestAndResponse({ + method: 'GET', + url: '/another-two', + }); + container.handle(r.req, r.res); + await r.done; + expect(r.res.statusCode).to.equal(200); + } + ); }); });