Skip to content

Commit 5bacac5

Browse files
committed
add root level containers tests
1 parent 4d7f372 commit 5bacac5

File tree

7 files changed

+351
-93
lines changed

7 files changed

+351
-93
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"react-redux": "5.0.1",
5757
"react-router": "3.0.0",
5858
"react-router-redux": "4.0.7",
59-
"react-textarea-autosize": "4.0.5",
59+
"react-textarea-autosize": "^5.1.0",
6060
"react-widgets": "3.4.5",
6161
"redux": "3.6.0",
6262
"redux-logger": "2.6.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Containers::Header renders correctly 1`] = `
4+
<div
5+
className="header"
6+
>
7+
<h3
8+
className="title"
9+
>
10+
<a
11+
onClick={[Function]}
12+
style={Object {}}
13+
target="_blank"
14+
>
15+
<i
16+
className="fa fa-home"
17+
/>
18+
<span>
19+
Your awesome title
20+
</span>
21+
</a>
22+
</h3>
23+
<span
24+
className="version"
25+
>
26+
v0.7.0
27+
</span>
28+
</div>
29+
`;
30+
31+
exports[`Containers::Header renders placeholder title 1`] = `
32+
<div
33+
className="header"
34+
>
35+
<h3
36+
className="title"
37+
>
38+
<a
39+
onClick={[Function]}
40+
style={Object {}}
41+
target="_blank"
42+
>
43+
<i
44+
className="fa fa-home"
45+
/>
46+
<span>
47+
You have no title!
48+
</span>
49+
</a>
50+
</h3>
51+
<span
52+
className="version"
53+
>
54+
v0.7.0
55+
</span>
56+
</div>
57+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Containers::Sidebar does not render hidden links 1`] = `
4+
<div
5+
className="sidebar"
6+
>
7+
<a
8+
className="logo"
9+
onClick={[Function]}
10+
style={Object {}}
11+
/>
12+
<ul
13+
className="routes"
14+
>
15+
<li>
16+
<a
17+
onClick={[Function]}
18+
style={Object {}}
19+
>
20+
<i
21+
className="fa fa-book"
22+
/>
23+
Movies
24+
</a>
25+
</li>
26+
<div
27+
className="splitter"
28+
/>
29+
<li>
30+
<a
31+
onClick={[Function]}
32+
style={Object {}}
33+
>
34+
<i
35+
className="fa fa-database"
36+
/>
37+
Data Files
38+
</a>
39+
</li>
40+
<li>
41+
<a
42+
onClick={[Function]}
43+
style={Object {}}
44+
>
45+
<i
46+
className="fa fa-file"
47+
/>
48+
Static Files
49+
</a>
50+
</li>
51+
<div
52+
className="splitter"
53+
/>
54+
<li>
55+
<a
56+
onClick={[Function]}
57+
style={Object {}}
58+
>
59+
<i
60+
className="fa fa-cog"
61+
/>
62+
Configuration
63+
</a>
64+
</li>
65+
</ul>
66+
</div>
67+
`;
68+
69+
exports[`Containers::Sidebar renders correctly 1`] = `
70+
<div
71+
className="sidebar"
72+
>
73+
<a
74+
className="logo"
75+
onClick={[Function]}
76+
style={Object {}}
77+
/>
78+
<ul
79+
className="routes"
80+
>
81+
<li>
82+
<a
83+
onClick={[Function]}
84+
style={Object {}}
85+
>
86+
<i
87+
className="fa fa-book"
88+
/>
89+
Posts
90+
</a>
91+
</li>
92+
<li>
93+
<a
94+
onClick={[Function]}
95+
style={Object {}}
96+
>
97+
<i
98+
className="fa fa-book"
99+
/>
100+
Movies
101+
</a>
102+
</li>
103+
<li>
104+
<a
105+
onClick={[Function]}
106+
style={Object {}}
107+
>
108+
<i
109+
className="fa fa-file-text"
110+
/>
111+
Pages
112+
</a>
113+
</li>
114+
<div
115+
className="splitter"
116+
/>
117+
<li>
118+
<a
119+
onClick={[Function]}
120+
style={Object {}}
121+
>
122+
<i
123+
className="fa fa-database"
124+
/>
125+
Data Files
126+
</a>
127+
</li>
128+
<li>
129+
<a
130+
onClick={[Function]}
131+
style={Object {}}
132+
>
133+
<i
134+
className="fa fa-file"
135+
/>
136+
Static Files
137+
</a>
138+
</li>
139+
<div
140+
className="splitter"
141+
/>
142+
<li>
143+
<a
144+
onClick={[Function]}
145+
style={Object {}}
146+
>
147+
<i
148+
className="fa fa-cog"
149+
/>
150+
Configuration
151+
</a>
152+
</li>
153+
</ul>
154+
</div>
155+
`;
156+
157+
exports[`Containers::Sidebar renders with zero collections 1`] = `
158+
<div
159+
className="sidebar"
160+
>
161+
<a
162+
className="logo"
163+
onClick={[Function]}
164+
style={Object {}}
165+
/>
166+
<ul
167+
className="routes"
168+
>
169+
<li>
170+
<a
171+
onClick={[Function]}
172+
style={Object {}}
173+
>
174+
<i
175+
className="fa fa-file-text"
176+
/>
177+
Pages
178+
</a>
179+
</li>
180+
<div
181+
className="splitter"
182+
/>
183+
<li>
184+
<a
185+
onClick={[Function]}
186+
style={Object {}}
187+
>
188+
<i
189+
className="fa fa-database"
190+
/>
191+
Data Files
192+
</a>
193+
</li>
194+
<li>
195+
<a
196+
onClick={[Function]}
197+
style={Object {}}
198+
>
199+
<i
200+
className="fa fa-file"
201+
/>
202+
Static Files
203+
</a>
204+
</li>
205+
<div
206+
className="splitter"
207+
/>
208+
<li>
209+
<a
210+
onClick={[Function]}
211+
style={Object {}}
212+
>
213+
<i
214+
className="fa fa-cog"
215+
/>
216+
Configuration
217+
</a>
218+
</li>
219+
</ul>
220+
</div>
221+
`;

src/containers/tests/header.spec.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
import React from 'react';
2-
import { mount } from 'enzyme';
2+
import ReactDOM from 'react-dom';
3+
import renderer from 'react-test-renderer';
34
import { Header } from '../Header';
45
import { config } from './fixtures';
56

67
const defaultProps = { config: config.content };
78

8-
function setup(props = defaultProps) {
9-
const component = mount(<Header {...props} />);
10-
11-
return {
12-
component: component,
13-
title: component.find('h3 span'),
14-
};
15-
}
16-
179
describe('Containers::Header', () => {
18-
it('should render correctly', () => {
19-
const { component, title } = setup();
20-
const { config } = component.props();
21-
expect(title.text()).toEqual(config.title);
10+
it('renders without crashing', () => {
11+
const div = document.createElement('div');
12+
ReactDOM.render(<Header {...defaultProps} />, div);
13+
});
14+
15+
it('renders correctly', () => {
16+
const tree = renderer.create(<Header {...defaultProps} />).toJSON();
17+
expect(tree).toMatchSnapshot();
2218
});
2319

24-
it('should render placeholder title', () => {
25-
const { component, title } = setup({ ...defaultProps, config: {} });
26-
const { config } = component.props();
27-
expect(title.text()).toEqual('You have no title!');
20+
it('renders placeholder title', () => {
21+
const props = { ...defaultProps, config: {} };
22+
const tree = renderer.create(<Header {...props} />).toJSON();
23+
expect(tree).toMatchSnapshot();
2824
});
2925
});

src/containers/tests/metafields.spec.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ const defaultProps = {
1111
key_prefix: '',
1212
};
1313

14-
function setup(props = defaultProps) {
15-
const actions = {
16-
storeContentFields: jest.fn(),
17-
addField: jest.fn(),
18-
removeField: jest.fn(),
19-
updateFieldKey: jest.fn(),
20-
updateFieldValue: jest.fn(),
21-
moveArrayItem: jest.fn(),
22-
convertField: jest.fn(),
23-
};
14+
const actions = {
15+
storeContentFields: jest.fn(),
16+
addField: jest.fn(),
17+
removeField: jest.fn(),
18+
updateFieldKey: jest.fn(),
19+
updateFieldValue: jest.fn(),
20+
moveArrayItem: jest.fn(),
21+
convertField: jest.fn(),
22+
};
2423

24+
function setup(props = defaultProps) {
2525
const component = mount(<MetaFields {...props} {...actions} />);
2626

2727
return {
@@ -34,7 +34,7 @@ function setup(props = defaultProps) {
3434
}
3535

3636
describe('Containers::MetaFields', () => {
37-
it('should render MetaFields correctly', () => {
37+
it('renders MetaFields correctly', () => {
3838
let { component, addFieldButton, addDataFieldButton } = setup();
3939

4040
expect(
@@ -63,12 +63,12 @@ describe('Containers::MetaFields', () => {
6363
expect(component.prop('metadata')).toEqual(content);
6464
});
6565

66-
it('should call storeContentFields before mount', () => {
66+
it('calls storeContentFields before mount', () => {
6767
const { actions } = setup();
6868
expect(actions.storeContentFields).toHaveBeenCalled();
6969
});
7070

71-
it('should call addField when the button is clicked', () => {
71+
it('calls addField when the button is clicked', () => {
7272
const { actions, addFieldButton } = setup();
7373
addFieldButton.simulate('click');
7474
expect(actions.addField).toHaveBeenCalled();

0 commit comments

Comments
 (0)