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 410
Expand file tree
/
Copy pathgithub-tab-item.test.js
More file actions
93 lines (73 loc) · 2.84 KB
/
github-tab-item.test.js
File metadata and controls
93 lines (73 loc) · 2.84 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react';
import {mount} from 'enzyme';
import PaneItem from '../../lib/atom/pane-item';
import GitHubTabItem from '../../lib/items/github-tab-item';
import GithubLoginModel from '../../lib/models/github-login-model';
import {InMemoryStrategy} from '../../lib/shared/keytar-strategy';
import {cloneRepository, buildRepository} from '../helpers';
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(props = {}) {
const workspace = props.workspace || atomEnv.workspace;
return (
<PaneItem workspace={workspace} uriPattern={GitHubTabItem.uriPattern}>
{({itemHolder}) => (
<GitHubTabItem
ref={itemHolder.setter}
workspace={workspace}
repository={repository}
loginModel={new GithubLoginModel(InMemoryStrategy)}
changeWorkingDirectory={() => {}}
onDidChangeWorkDirs={() => {}}
getCurrentWorkDirs={() => []}
openCreateDialog={() => {}}
openPublishDialog={() => {}}
openCloneDialog={() => {}}
openGitTab={() => {}}
{...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());
});
});