Repository navigation
Expand file tree
/
Copy pathopen.test.js
More file actions
114 lines (83 loc) · 4.25 KB
/
Copy pathopen.test.js
File metadata and controls
114 lines (83 loc) · 4.25 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import fs from 'fs-extra';
import path from 'path';
import {setup, teardown} from './helpers';
describe('integration: opening and closing tabs', function() {
let context, wrapper, atomEnv, commands, workspaceElement;
beforeEach(async function() {
context = await setup({
initialRoots: ['three-files'],
initConfigDir: configDirPath => fs.writeFile(path.join(configDirPath, 'github.cson'), ''),
state: {newProject: false},
});
wrapper = context.wrapper;
atomEnv = context.atomEnv;
commands = atomEnv.commands;
workspaceElement = atomEnv.views.getView(atomEnv.workspace);
});
afterEach(async function() {
await teardown(context);
});
it('opens but does not focus the git tab on github:toggle-git-tab', async function() {
atomEnv.workspace.getCenter().activate();
await atomEnv.workspace.open(__filename);
assert.isFalse(wrapper.find('.github-Git').exists());
const previousFocus = document.activeElement;
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
// Don't use assert.async.strictEqual() because it times out Mocha's failure diffing <_<
await assert.async.isTrue(atomEnv.workspace.getRightDock().isVisible());
await assert.async.isTrue(previousFocus === document.activeElement);
});
it('reveals an open but hidden git tab on github:toggle-git-tab', async function() {
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
atomEnv.workspace.getRightDock().hide();
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
});
it('hides an open git tab on github:toggle-git-tab', async function() {
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
assert.isFalse(atomEnv.workspace.getRightDock().isVisible());
});
it('opens and focuses the git tab on github:toggle-git-tab-focus', async function() {
await atomEnv.workspace.open(__filename);
await commands.dispatch(workspaceElement, 'github:toggle-git-tab-focus');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
assert.isTrue(wrapper.find('.github-Git[tabIndex]').getDOMNode().contains(document.activeElement));
});
it('focuses a blurred git tab on github:toggle-git-tab-focus', async function() {
await commands.dispatch(workspaceElement, 'github:toggle-git-tab');
wrapper.update();
assert.isTrue(wrapper.find('.github-Git').exists());
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
await assert.async.isFalse(wrapper.find('.github-Git[tabIndex]').getDOMNode().contains(document.activeElement));
await commands.dispatch(workspaceElement, 'github:toggle-git-tab-focus');
wrapper.update();
assert.isTrue(wrapper.find('.github-StagingView').getDOMNode().contains(document.activeElement));
});
it('blurs an open and focused git tab on github:toggle-git-tab-focus', async function() {
const editor = await atomEnv.workspace.open(__filename);
await commands.dispatch(workspaceElement, 'github:toggle-git-tab-focus');
wrapper.update();
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
assert.isTrue(wrapper.find('.github-StagingView').getDOMNode().contains(document.activeElement));
await commands.dispatch(workspaceElement, 'github:toggle-git-tab-focus');
wrapper.update();
assert.isTrue(atomEnv.workspace.getRightDock().isVisible());
assert.isTrue(wrapper.find('.github-StagingView').exists());
assert.isFalse(wrapper.find('.github-StagingView').getDOMNode().contains(document.activeElement));
assert.strictEqual(atomEnv.workspace.getActivePaneItem(), editor);
});
});