This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 401
/
Copy pathreviews-footer-view.test.js
55 lines (41 loc) · 1.75 KB
/
reviews-footer-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
import React from 'react';
import {shallow} from 'enzyme';
import * as reporterProxy from '../../lib/reporter-proxy';
import ReviewsFooterView from '../../lib/views/reviews-footer-view';
describe('ReviewsFooterView', function() {
let atomEnv;
beforeEach(function() {
atomEnv = global.buildAtomEnvironment();
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(override = {}) {
const props = {
commentsResolved: 3,
totalComments: 4,
openReviews: () => {},
...override,
};
return <ReviewsFooterView {...props} />;
}
it('renders the resolved and total comment counts', function() {
const wrapper = shallow(buildApp({commentsResolved: 4, totalComments: 7}));
assert.strictEqual(wrapper.find('.github-ReviewsFooterView-commentsResolved').text(), '4');
assert.strictEqual(wrapper.find('.github-ReviewsFooterView-totalComments').text(), '7');
assert.strictEqual(wrapper.find('.github-ReviewsFooterView-progessBar').prop('value'), 4);
assert.strictEqual(wrapper.find('.github-ReviewsFooterView-progessBar').prop('max'), 7);
});
it('triggers openReviews on button click', function() {
const openReviews = sinon.spy();
const wrapper = shallow(buildApp({openReviews}));
wrapper.find('.github-ReviewsFooterView-openReviewsButton').simulate('click');
assert.isTrue(openReviews.called);
});
it('records an event when review is started from footer', function() {
sinon.stub(reporterProxy, 'addEvent');
const wrapper = shallow(buildApp());
wrapper.find('.github-ReviewsFooterView-reviewChangesButton').simulate('click');
assert.isTrue(reporterProxy.addEvent.calledWith('start-pr-review', {package: 'github', component: 'ReviewsFooterView'}));
});
});