-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathIndexLinkContainer.spec.js
52 lines (46 loc) · 1.49 KB
/
IndexLinkContainer.spec.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
44
45
46
47
48
49
50
51
52
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import * as ReactBootstrap from 'react-bootstrap';
import { findDOMNode } from 'react-dom';
import { Route, MemoryRouter as Router } from 'react-router';
import IndexLinkContainer from '../src/IndexLinkContainer';
describe('IndexLinkContainer', () => {
[
'Button',
'NavItem',
'MenuItem',
'ListGroupItem',
].forEach(name => {
describe(name, () => {
const Component = ReactBootstrap[name];
describe('active state', () => {
function renderComponent(location) {
const router = ReactTestUtils.renderIntoDocument(
<Router initialEntries={[location]}>
<div>
<Route
path="/"
render={() => (
<IndexLinkContainer to="/">
<Component>Root</Component>
</IndexLinkContainer>
)}
/>
</div>
</Router>
);
const component = ReactTestUtils.findRenderedComponentWithType(
router, Component
);
return findDOMNode(component);
}
it('should be active on the index route', () => {
expect(renderComponent('/').className).to.match(/\bactive\b/);
});
it('should not be active on a child route', () => {
expect(renderComponent('/foo').className).to.not.match(/\bactive\b/);
});
});
});
});
});