This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
CallOut.test.jsx
94 lines (85 loc) · 1.97 KB
/
CallOut.test.jsx
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const React = require('react');
const { shallow, mount } = require('enzyme');
const CallOut = require('../../src/block-types/CallOut');
test('should render title', () => {
const block = {
data: {
type: 'info',
title: 'Callout',
},
};
const callout = mount(<CallOut block={block} />);
expect(callout.find('h3').text()).toBe('Callout');
});
describe('icons', () => {
const icons = {
info: 'info-circle',
warning: 'exclamation-circle',
danger: 'exclamation-triangle',
success: 'check-square',
};
it('should render with title', () => {
Object.keys(icons).forEach(type => {
const className = icons[type];
const block = {
data: {
type,
title: 'Callout',
},
};
expect(mount(<CallOut block={block} />).find(`.fa-${className}`)).toHaveLength(1);
});
});
it('should render without title', () => {
Object.keys(icons).forEach(type => {
const className = icons[type];
const block = {
data: {
type,
},
};
expect(mount(<CallOut block={block} />).find(`.noTitleIcon .fa-${className}`)).toHaveLength(
1,
);
});
});
});
test('should render nothing if no title and icon', () => {
const block = {
data: {
type: '',
},
};
const callout = mount(<CallOut block={block} />);
expect(callout.find('span').text()).toBe('');
});
test('should render body', () => {
const block = {
data: {
type: 'info',
body: 'body',
},
};
const callout = shallow(<CallOut block={block} />);
expect(
callout
.render()
.find('.callout-body')
.html(),
).toMatchSnapshot();
});
test('should render markdown in body', () => {
const block = {
data: {
type: 'info',
body: '# heading\n`test`',
},
};
const callout = shallow(<CallOut block={block} />);
expect(
callout
.render()
.find('.callout-body')
.html(),
).toMatchSnapshot();
});