forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-run-view.test.js
73 lines (57 loc) · 2.66 KB
/
check-run-view.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
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import {shallow} from 'enzyme';
import {BareCheckRunView} from '../../lib/views/check-run-view';
import {checkRunBuilder} from '../builder/graphql/timeline';
import checkRunQuery from '../../lib/views/__generated__/checkRunView_checkRun.graphql';
describe('CheckRunView', function() {
function buildApp(override = {}) {
const props = {
checkRun: checkRunBuilder(checkRunQuery).build(),
switchToIssueish: () => {},
...override,
};
return <BareCheckRunView {...props} />;
}
it('renders check run information', function() {
const checkRun = checkRunBuilder(checkRunQuery)
.status('COMPLETED')
.conclusion('FAILURE')
.name('some check run')
.permalink('https://github.com/atom/github/runs/1111')
.detailsUrl('https://ci.com/job/123')
.title('this is the title')
.summary('some stuff happened')
.build();
const wrapper = shallow(buildApp({checkRun}));
const icon = wrapper.find('Octicon');
assert.strictEqual(icon.prop('icon'), 'x');
assert.isTrue(icon.hasClass('github-PrStatuses--failure'));
assert.strictEqual(wrapper.find('a.github-PrStatuses-list-item-name').text(), 'some check run');
assert.strictEqual(wrapper.find('a.github-PrStatuses-list-item-name').prop('href'), 'https://github.com/atom/github/runs/1111');
assert.strictEqual(wrapper.find('.github-PrStatuses-list-item-title').text(), 'this is the title');
assert.strictEqual(wrapper.find('.github-PrStatuses-list-item-summary').prop('markdown'), 'some stuff happened');
assert.strictEqual(wrapper.find('.github-PrStatuses-list-item-details-link').text(), 'Details');
assert.strictEqual(wrapper.find('.github-PrStatuses-list-item-details-link').prop('href'), 'https://ci.com/job/123');
});
it('omits optional fields that are absent', function() {
const checkRun = checkRunBuilder(checkRunQuery)
.status('IN_PROGRESS')
.name('some check run')
.permalink('https://github.com/atom/github/runs/1111')
.nullTitle()
.nullSummary()
.build();
const wrapper = shallow(buildApp({checkRun}));
assert.isFalse(wrapper.exists('.github-PrStatuses-list-item-title'));
assert.isFalse(wrapper.exists('.github-PrStatuses-list-item-summary'));
});
it('handles issueish navigation from links in the build summary', function() {
const checkRun = checkRunBuilder(checkRunQuery)
.summary('#1234')
.build();
const switchToIssueish = sinon.spy();
const wrapper = shallow(buildApp({switchToIssueish, checkRun}));
wrapper.find('GithubDotcomMarkdown').prop('switchToIssueish')();
assert.isTrue(switchToIssueish.called);
});
});