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 411
Expand file tree
/
Copy pathgit-tab-item.test.js
More file actions
77 lines (61 loc) · 2.35 KB
/
git-tab-item.test.js
File metadata and controls
77 lines (61 loc) · 2.35 KB
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
import React from 'react';
import {mount} from 'enzyme';
import PaneItem from '../../lib/atom/pane-item';
import GitTabItem from '../../lib/items/git-tab-item';
import {cloneRepository, buildRepository} from '../helpers';
import {gitTabItemProps} from '../fixtures/props/git-tab-props';
describe('GitTabItem', function() {
let atomEnv, repository;
beforeEach(async function() {
atomEnv = global.buildAtomEnvironment();
const workdirPath = await cloneRepository();
repository = await buildRepository(workdirPath);
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(overrideProps = {}) {
const props = gitTabItemProps(atomEnv, repository, overrideProps);
return (
<PaneItem workspace={props.workspace} uriPattern={GitTabItem.uriPattern}>
{({itemHolder}) => (
<GitTabItem
ref={itemHolder.setter}
{...props}
/>
)}
</PaneItem>
);
}
it('forwards all props to the GitTabContainer', async function() {
const extraProp = Symbol('extra');
const wrapper = mount(buildApp({extraProp}));
await atomEnv.workspace.open(GitTabItem.buildURI());
assert.strictEqual(wrapper.update().find('GitTabContainer').prop('extraProp'), extraProp);
});
it('renders within the dock with the component as its owner', async function() {
mount(buildApp());
await atomEnv.workspace.open(GitTabItem.buildURI());
const paneItem = atomEnv.workspace.getRightDock().getPaneItems()
.find(item => item.getURI() === 'atom-github://dock-item/git');
assert.strictEqual(paneItem.getTitle(), 'Git');
});
it('forwards imperative focus manipulation methods to its controller', async function() {
const wrapper = mount(buildApp());
await atomEnv.workspace.open(GitTabItem.buildURI());
await assert.async.isTrue(wrapper.update().find('GitTabController').exists());
const focusMethods = [
'focusAndSelectStagingItem',
'focusAndSelectCommitPreviewButton',
'focusAndSelectRecentCommit',
];
const spies = focusMethods.reduce((map, focusMethod) => {
map[focusMethod] = sinon.stub(wrapper.find('GitTabController').instance(), focusMethod);
return map;
}, {});
for (const method of focusMethods) {
wrapper.find('GitTabItem').instance()[method]();
assert.isTrue(spies[method].called);
}
});
});