forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-tab-item.test.js
More file actions
79 lines (62 loc) · 2.39 KB
/
github-tab-item.test.js
File metadata and controls
79 lines (62 loc) · 2.39 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
78
79
import React from 'react';
import {mount} from 'enzyme';
import PaneItem from '../../lib/atom/pane-item';
import GitHubTabItem from '../../lib/items/github-tab-item';
import {cloneRepository, buildRepository} from '../helpers';
import {gitHubTabItemProps} from '../fixtures/props/github-tab-props';
describe('GitHubTabItem', 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 = gitHubTabItemProps(atomEnv, repository, overrideProps);
return (
<PaneItem workspace={props.workspace} uriPattern={GitHubTabItem.uriPattern}>
{({itemHolder}) => (
<GitHubTabItem
ref={itemHolder.setter}
{...props}
/>
)}
</PaneItem>
);
}
it('renders within the dock with the component as its owner', async function() {
mount(buildApp());
await atomEnv.workspace.open(GitHubTabItem.buildURI());
const paneItem = atomEnv.workspace.getRightDock().getPaneItems()
.find(item => item.getURI() === 'atom-github://dock-item/github');
assert.strictEqual(paneItem.getTitle(), 'GitHub');
assert.strictEqual(paneItem.getIconName(), 'octoface');
});
it('access the working directory path', async function() {
mount(buildApp());
const item = await atomEnv.workspace.open(GitHubTabItem.buildURI());
assert.strictEqual(item.getWorkingDirectory(), repository.getWorkingDirectoryPath());
});
it('serializes itself', async function() {
mount(buildApp());
const item = await atomEnv.workspace.open(GitHubTabItem.buildURI());
assert.deepEqual(item.serialize(), {
deserializer: 'GithubDockItem',
uri: 'atom-github://dock-item/github',
});
});
it('detects when it has focus', async function() {
let activeElement = document.body;
const wrapper = mount(buildApp({
documentActiveElement: () => activeElement,
}));
const item = await atomEnv.workspace.open(GitHubTabItem.buildURI());
await assert.async.isTrue(wrapper.update().find('.github-GitHub').exists());
assert.isFalse(item.hasFocus());
activeElement = wrapper.find('.github-GitHub').getDOMNode();
assert.isTrue(item.hasFocus());
});
});