skip layout components where none is provided - fixes #312

This commit is contained in:
Rich Harris
2018-07-23 16:31:00 -04:00
parent f8c731ca21
commit 731d4f535c
5 changed files with 56 additions and 36 deletions

View File

@@ -36,6 +36,7 @@ describe('create_routes', () => {
{
pattern: /^\/blog\/?$/,
parts: [
null,
{ component: blog, params: [] }
]
},
@@ -43,6 +44,7 @@ describe('create_routes', () => {
{
pattern: /^\/blog\/([^\/]+?)\/?$/,
parts: [
null,
{ component: blog_$slug, params: ['slug'] }
]
}
@@ -100,15 +102,15 @@ describe('create_routes', () => {
it('sorts routes correctly', () => {
const { pages } = create_routes(path.join(__dirname, 'samples/sorting'));
assert.deepEqual(pages.map(p => p.parts.map(part => part.component.file)), [
assert.deepEqual(pages.map(p => p.parts.map(part => part && part.component.file)), [
['index.html'],
['about.html'],
['post/index.html'],
['post/bar.html'],
['post/foo.html'],
['post/f[xx].html'],
['post/[id([0-9-a-z]{3,})].html'],
['post/[id].html'],
[null, 'post/index.html'],
[null, 'post/bar.html'],
[null, 'post/foo.html'],
[null, 'post/f[xx].html'],
[null, 'post/[id([0-9-a-z]{3,})].html'],
[null, 'post/[id].html'],
['[wildcard].html']
]);
});