[ci] format

This commit is contained in:
matthewp 2022-11-08 22:31:47 +00:00 committed by fredkbot
parent 688f8e4bc1
commit 48bde7018e
3 changed files with 42 additions and 36 deletions

View file

@ -355,7 +355,7 @@ export function createRouteManifest(
let resolved: string; let resolved: string;
try { try {
resolved = require.resolve(entryPoint, { paths: [cwd || fileURLToPath(config.root)] }); resolved = require.resolve(entryPoint, { paths: [cwd || fileURLToPath(config.root)] });
} catch(e) { } catch (e) {
resolved = fileURLToPath(new URL(entryPoint, config.root)); resolved = fileURLToPath(new URL(entryPoint, config.root));
} }
const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved)); const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved));

View file

@ -47,7 +47,7 @@ export default function loadFallbackPlugin({
return npath.posix.join(npath.posix.dirname(parent), id); return npath.posix.join(npath.posix.dirname(parent), id);
} else { } else {
let resolved = await this.resolve(id, parent, { skipSelf: true }); let resolved = await this.resolve(id, parent, { skipSelf: true });
if(resolved) { if (resolved) {
return resolved.id; return resolved.id;
} }
return slashify(id); return slashify(id);

View file

@ -108,47 +108,53 @@ describe('dev container', () => {
}); });
it('Allows dynamic segments in injected routes', async () => { it('Allows dynamic segments in injected routes', async () => {
const fs = createFs({ const fs = createFs(
{
'/src/components/test.astro': `<h1>{Astro.params.slug}</h1>`, '/src/components/test.astro': `<h1>{Astro.params.slug}</h1>`,
'/src/pages/test-[slug].astro': `<h1>{Astro.params.slug}</h1>`, '/src/pages/test-[slug].astro': `<h1>{Astro.params.slug}</h1>`,
}, },
root root
); );
await runInContainer({ await runInContainer(
fs, {
root, fs,
userConfig: { root,
output: 'server', userConfig: {
integrations: [{ output: 'server',
name: '@astrojs/test-integration', integrations: [
hooks: { {
'astro:config:setup': ({ injectRoute }) => { name: '@astrojs/test-integration',
injectRoute({ hooks: {
pattern: '/another-[slug]', 'astro:config:setup': ({ injectRoute }) => {
entryPoint: './src/components/test.astro', injectRoute({
}); pattern: '/another-[slug]',
entryPoint: './src/components/test.astro',
});
},
},
}, },
}, ],
}] },
} },
}, async (container) => { async (container) => {
let r = createRequestAndResponse({ let r = createRequestAndResponse({
method: 'GET', method: 'GET',
url: '/test-one', url: '/test-one',
}); });
container.handle(r.req, r.res); container.handle(r.req, r.res);
await r.done; await r.done;
expect(r.res.statusCode).to.equal(200); expect(r.res.statusCode).to.equal(200);
// Try with the injected route // Try with the injected route
r = createRequestAndResponse({ r = createRequestAndResponse({
method: 'GET', method: 'GET',
url: '/another-two', url: '/another-two',
}); });
container.handle(r.req, r.res); container.handle(r.req, r.res);
await r.done; await r.done;
expect(r.res.statusCode).to.equal(200); expect(r.res.statusCode).to.equal(200);
}); }
);
}); });
}); });