forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueish-badge.test.js
60 lines (49 loc) · 2.03 KB
/
issueish-badge.test.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
53
54
55
56
57
58
59
60
import React from 'react';
import {shallow} from 'enzyme';
import IssueishBadge from '../../lib/views/issueish-badge';
describe('IssueishBadge', function() {
function buildApp(overloadProps = {}) {
return (
<IssueishBadge
type="Issue"
state="OPEN"
{...overloadProps}
/>
);
}
it('applies a className and any other properties to the span', function() {
const extra = Symbol('extra');
const wrapper = shallow(buildApp({
className: 'added',
state: 'CLOSED',
extra,
}));
const span = wrapper.find('span.github-IssueishBadge');
assert.isTrue(span.hasClass('added'));
assert.isTrue(span.hasClass('closed'));
assert.strictEqual(span.prop('extra'), extra);
});
it('renders an appropriate icon', function() {
const wrapper = shallow(buildApp({type: 'Issue', state: 'OPEN'}));
assert.isTrue(wrapper.find('Octicon[icon="issue-opened"]').exists());
assert.match(wrapper.text(), /open$/);
wrapper.setProps({type: 'Issue', state: 'CLOSED'});
assert.isTrue(wrapper.find('Octicon[icon="issue-closed"]').exists());
assert.match(wrapper.text(), /closed$/);
wrapper.setProps({type: 'PullRequest', state: 'OPEN'});
assert.isTrue(wrapper.find('Octicon[icon="git-pull-request"]').exists());
assert.match(wrapper.text(), /open$/);
wrapper.setProps({type: 'PullRequest', state: 'CLOSED'});
assert.isTrue(wrapper.find('Octicon[icon="git-pull-request"]').exists());
assert.match(wrapper.text(), /closed$/);
wrapper.setProps({type: 'PullRequest', state: 'MERGED'});
assert.isTrue(wrapper.find('Octicon[icon="git-merge"]').exists());
assert.match(wrapper.text(), /merged$/);
wrapper.setProps({type: 'Unknown', state: 'OPEN'});
assert.isTrue(wrapper.find('Octicon[icon="question"]').exists());
assert.match(wrapper.text(), /open$/);
wrapper.setProps({type: 'PullRequest', state: 'UNKNOWN'});
assert.isTrue(wrapper.find('Octicon[icon="question"]').exists());
assert.match(wrapper.text(), /unknown$/);
});
});