forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouteComponent-test.js
43 lines (35 loc) · 1017 Bytes
/
RouteComponent-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import expect from 'expect'
import React, { Component } from 'react'
import { render, unmountComponentAtNode } from 'react-dom'
import createHistory from '../createMemoryHistory'
import Router from '../Router'
describe('a Route Component', function () {
let node
beforeEach(function () {
node = document.createElement('div')
})
afterEach(function () {
unmountComponentAtNode(node)
})
it('injects the right props', function (done) {
class Parent extends Component {
componentDidMount() {
expect(this.props.route).toEqual(parent)
expect(this.props.routes).toEqual([ parent, child ])
}
render() {
return null
}
}
class Child extends Component {
render() {
return null
}
}
const child = { path: 'child', component: Child }
const parent = { path: '/', component: Parent, childRoutes: [ child ] }
render((
<Router history={createHistory('/child')} routes={parent}/>
), node, done)
})
})