-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathArticleGroup.test.js
More file actions
75 lines (65 loc) · 2.24 KB
/
ArticleGroup.test.js
File metadata and controls
75 lines (65 loc) · 2.24 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from 'react';
import createShallowSnapshotTest from 'test-utils/createShallowSnapshotTest';
import { mount, shallow } from 'enzyme';
import ArticleGroup from '../ArticleGroup';
describe('ArticleGroup', () => {
test('should render properly with required props', () =>
createShallowSnapshotTest(
<ArticleGroup
region="test"
articles={[{ title: 'Example', url: 'https://example.com' }]}
numberOfInitiallyVisibleLinks={1}
/>,
));
test('should render properly with required props and 3 links and a button', () =>
createShallowSnapshotTest(
<ArticleGroup
region="test"
articles={[
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
]}
numberOfInitiallyVisibleLinks={1}
/>,
));
test('should setState when clicking Show All button', () => {
const ArticleGroupShallowInstance = shallow(
<ArticleGroup
region="test"
articles={[
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
]}
numberOfInitiallyVisibleLinks={1}
/>,
);
ArticleGroupShallowInstance.instance().clickHandler();
expect(ArticleGroupShallowInstance.state().areAllLinksVisible).toEqual(true);
});
test('should not create a button if not enough links', () => {
const wrap = mount(
<ArticleGroup
region="test"
articles={[{ title: 'Example', url: 'https://example.com' }]}
numberOfInitiallyVisibleLinks={5}
/>,
);
expect(wrap.find('button').exists()).toEqual(false);
});
test('should create a button if enough links are available', () => {
const wrap = mount(
<ArticleGroup
region="test"
articles={[
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
{ title: 'Example', url: 'https://example.com' },
]}
numberOfInitiallyVisibleLinks={1}
/>,
);
expect(wrap.find('button').exists()).toEqual(true);
});
});