Skip to content

Commit f145d08

Browse files
committed
failing test case
1 parent d88a051 commit f145d08

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*eslint-env mocha */
2+
/*eslint react/prop-types: 0*/
3+
import expect from 'expect'
4+
import React from 'react'
5+
import createHistory from 'history/lib/createMemoryHistory'
6+
import IndexRoute from '../IndexRoute'
7+
import Router from '../Router'
8+
import Route from '../Route'
9+
import IndexLink from '../IndexLink'
10+
11+
describe('an <IndexLink/>', function () {
12+
13+
var node
14+
beforeEach(function () {
15+
node = document.createElement('div')
16+
})
17+
18+
afterEach(function () {
19+
React.unmountComponentAtNode(node)
20+
})
21+
22+
var App = React.createClass({
23+
render () {
24+
return (
25+
<div>
26+
<ul>
27+
<li><IndexLink id="appLink" to="/" activeClassName="active">app </IndexLink></li>
28+
<li><IndexLink id="deepLink" to="/deep" activeClassName="active">deep </IndexLink></li>
29+
</ul>
30+
{this.props.children}
31+
</div>
32+
)
33+
}
34+
})
35+
36+
var Parent = React.createClass({
37+
render () {
38+
return <div>parent {this.props.children}</div>
39+
}
40+
})
41+
42+
var Child = React.createClass({
43+
render () {
44+
return <div>child </div>
45+
}
46+
})
47+
48+
var routes = (
49+
<Route path="/" component={App}>
50+
<IndexRoute component={Child}/>
51+
<Route path="/deep" component={Parent}>
52+
<IndexRoute component={Child}/>
53+
</Route>
54+
</Route>
55+
)
56+
57+
describe('when linking to the root', function () {
58+
it('is active when the parent’s route is active', function (done) {
59+
React.render((
60+
<Router history={createHistory('/')} routes={routes}/>
61+
), node, function () {
62+
expect(node.querySelector('#appLink').className).toEqual('active')
63+
expect(node.querySelector('#deepLink').className).toEqual('')
64+
done()
65+
})
66+
})
67+
})
68+
69+
describe('when linking deep into the route hierarchy', function () {
70+
it('is active when the parent’s route is active', function (done) {
71+
React.render((
72+
<Router history={createHistory('/deep')} routes={routes}/>
73+
), node, function () {
74+
expect(node.querySelector('#appLink').className).toEqual('')
75+
expect(node.querySelector('#deepLink').className).toEqual('active')
76+
done()
77+
})
78+
})
79+
})
80+
81+
})

0 commit comments

Comments
 (0)