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 402
/
Copy pathfile-patch-meta-view.test.js
60 lines (46 loc) · 1.77 KB
/
file-patch-meta-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
import React from 'react';
import {shallow} from 'enzyme';
import FilePatchMetaView from '../../lib/views/file-patch-meta-view';
import CommitDetailItem from '../../lib/items/commit-detail-item';
describe('FilePatchMetaView', function() {
let atomEnv;
beforeEach(function() {
atomEnv = global.buildAtomEnvironment();
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(overrideProps = {}, children = <div />) {
return (
<FilePatchMetaView
title=""
actionIcon="icon-move-up"
actionText="action"
action={() => {}}
{...overrideProps}>
{children}
</FilePatchMetaView>
);
}
it('renders the title', function() {
const wrapper = shallow(buildApp({title: 'Yes'}));
assert.strictEqual(wrapper.find('.github-FilePatchView-metaTitle').text(), 'Yes');
});
it('renders a control button with the correct text and callback', function() {
const action = sinon.stub();
const wrapper = shallow(buildApp({action, actionText: 'do the thing', actionIcon: 'icon-move-down'}));
const button = wrapper.find('button.icon-move-down');
assert.strictEqual(button.text(), 'do the thing');
button.simulate('click');
assert.isTrue(action.called);
});
it('renders child elements as details', function() {
const wrapper = shallow(buildApp({}, <div className="child" />));
assert.isTrue(wrapper.find('.github-FilePatchView-metaDetails .child').exists());
});
it('omits controls when rendered in a CommitDetailItem', function() {
const wrapper = shallow(buildApp({itemType: CommitDetailItem}));
assert.isTrue(wrapper.find('.github-FilePatchView-metaDetails').exists());
assert.isFalse(wrapper.find('.github-FilePatchView-metaControls').exists());
});
});