-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
router: fix typing of
IRouteProps.component
(#1505)
* router: fix typing of `IRouteProps.component` Fix `SFC` to explicitly accept `any` as same as `IComponentConstructor` . * add: test for Route
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { render } from 'inferno'; | ||
import { Route, Router } from 'inferno-router'; | ||
import createMemoryHistory from 'history/createMemoryHistory'; | ||
|
||
describe('<Route component>', () => { | ||
const history = createMemoryHistory(); | ||
const node = document.createElement('div'); | ||
|
||
it('receives { history, location, match } props', () => { | ||
type RouteProps = { | ||
history: any; | ||
location: any; | ||
match: any; | ||
}; | ||
let actual: RouteProps = { | ||
history: null, | ||
location: null, | ||
match: null, | ||
}; | ||
const Component = (props: RouteProps) => (actual = props) && null; | ||
|
||
render( | ||
<Router history={history}> | ||
<Route path="/" component={Component} /> | ||
</Router>, | ||
node | ||
); | ||
|
||
expect(actual.history).toBe(history); | ||
expect(typeof actual.match).toBe('object'); | ||
expect(typeof actual.location).toBe('object'); | ||
}); | ||
}); |
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