Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/create-route-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function addRouteRecord (
`route config "component" for path: ${String(path || name)} cannot be a ` +
`string id. Use an actual component instead.`
)
assert(
route.component,
`route config "component" for path: ${String(path || name)} cannot be ${String(route.component)}.`
)
}

const pathToRegexpOptions: PathToRegexpOptions = route.pathToRegexpOptions || {}
Expand Down
7 changes: 7 additions & 0 deletions test/unit/specs/create-map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ describe('Creating Route Map', function () {
}).toThrowError(/"path" is required/)
})

it('in development, throws if component is null or undefined', function () {
process.env.NODE_ENV = 'development'
expect(() => {
maps = createRouteMap([{ path: '/' }])
}).toThrowError(/route config "component" for path/)
})

Copy link

@vinibrsl vinibrsl Feb 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create an spec similar to this one, but to test that this is not affecting production env, with not.toHaveBeenCalled 👍

it('in production, it has not logged this warning', function () {
maps = createRouteMap(routes)
expect(console.warn).not.toHaveBeenCalled()
Expand Down