-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#7561): refactor astro page filename logic
- Loading branch information
1 parent
51028f8
commit e546455
Showing
2 changed files
with
62 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expect } from 'chai'; | ||
import { makeAstroPageEntryPointFileName } from '../../../dist/core/build/static-build.js'; | ||
|
||
describe('astro/src/core/build', () => { | ||
describe('makeAstroPageEntryPointFileName', () => { | ||
const routes = [ | ||
{ | ||
route: '/', | ||
component: 'src/pages/index.astro', | ||
pathname: '/', | ||
}, | ||
{ | ||
route: '/injected', | ||
component: '../node_modules/my-dep/injected.astro', | ||
pathname: '/injected', | ||
}, | ||
{ | ||
route: '/injected-workspace', | ||
component: '../../packages/demo/[...all].astro', | ||
pathname: undefined, | ||
}, | ||
{ | ||
route: '/blog/[year]/[...slug]', | ||
component: 'src/pages/blog/[year]/[...slug].astro', | ||
pathname: undefined, | ||
}, | ||
] | ||
|
||
it('handles local pages', async () => { | ||
const input = '@astro-page:src/pages/index@_@astro'; | ||
const output = 'pages/index.astro.mjs'; | ||
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes); | ||
expect(result).to.equal(output) | ||
}); | ||
|
||
it('handles dynamic pages', async () => { | ||
const input = '@astro-page:src/pages/blog/[year]/[...slug]@_@astro'; | ||
const output = 'pages/blog/_year_/_---slug_.astro.mjs'; | ||
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes); | ||
expect(result).to.equal(output) | ||
}); | ||
|
||
it('handles node_modules pages', async () => { | ||
const input = '@astro-page:../node_modules/my-dep/injected@_@astro'; | ||
const output = 'pages/injected.astro.mjs'; | ||
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes); | ||
expect(result).to.equal(output) | ||
}); | ||
|
||
// Fix #7561 | ||
it('handles local workspace pages', async () => { | ||
const input = '@astro-page:../../packages/demo/[...all]@_@astro'; | ||
const output = 'pages/injected-workspace.astro.mjs'; | ||
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes); | ||
expect(result).to.equal(output) | ||
}); | ||
}); | ||
}); |