Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Nov 8, 2022
1 parent 688f8e4 commit 48bde70
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-load-fallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
74 changes: 40 additions & 34 deletions packages/astro/test/units/dev/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': `<h1>{Astro.params.slug}</h1>`,
'/src/pages/test-[slug].astro': `<h1>{Astro.params.slug}</h1>`,
},
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);
}
);
});
});

0 comments on commit 48bde70

Please sign in to comment.