forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepository-conflict-controller.test.js
93 lines (68 loc) · 3.23 KB
/
repository-conflict-controller.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
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 path from 'path';
import React from 'react';
import {mount} from 'enzyme';
import {cloneRepository, buildRepository} from '../helpers';
import RepositoryConflictController from '../../lib/controllers/repository-conflict-controller';
import EditorConflictController from '../../lib/controllers/editor-conflict-controller';
describe('RepositoryConflictController', () => {
let atomEnv, workspace, app;
beforeEach(() => {
atomEnv = global.buildAtomEnvironment();
atomEnv.config.set('github.graphicalConflictResolution', true);
workspace = atomEnv.workspace;
const commands = atomEnv.commands;
app = <RepositoryConflictController workspace={workspace} config={atomEnv.config} commands={commands} />;
});
afterEach(() => atomEnv.destroy());
describe('with no conflicts', () => {
it('renders no children', async () => {
const workdirPath = await cloneRepository('merge-conflict');
const repository = await buildRepository(workdirPath);
await Promise.all(['modified-on-both-ours.txt', 'modified-on-both-theirs.txt'].map(basename => {
return workspace.open(path.join(workdirPath, basename));
}));
app = React.cloneElement(app, {repository});
const wrapper = mount(app);
assert.equal(wrapper.find(EditorConflictController).length, 0);
});
});
describe('with conflicts but no open editors', () => {
it('renders no children', async () => {
const workdirPath = await cloneRepository('merge-conflict');
const repository = await buildRepository(workdirPath);
assert.isRejected(repository.git.merge('origin/branch'));
app = React.cloneElement(app, {repository});
const wrapper = mount(app);
assert.equal(wrapper.find(EditorConflictController).length, 0);
});
});
describe('with conflicts and open editors', () => {
it('renders an EditorConflictController for each conflicting editor', async () => {
const workdirPath = await cloneRepository('merge-conflict');
const repository = await buildRepository(workdirPath);
await assert.isRejected(repository.git.merge('origin/branch'));
await Promise.all(['modified-on-both-ours.txt', 'modified-on-both-theirs.txt'].map(basename => {
return workspace.open(path.join(workdirPath, basename));
}));
app = React.cloneElement(app, {repository});
const wrapper = mount(app);
await assert.async.equal(wrapper.update().find(EditorConflictController).length, 2);
});
});
describe('with the configuration option disabled', function() {
beforeEach(function() {
atomEnv.config.set('github.graphicalConflictResolution', false);
});
it('renders no children', async function() {
const workdirPath = await cloneRepository('merge-conflict');
const repository = await buildRepository(workdirPath);
await assert.isRejected(repository.git.merge('origin/branch'));
await Promise.all(['modified-on-both-ours.txt', 'modified-on-both-theirs.txt'].map(basename => {
return workspace.open(path.join(workdirPath, basename));
}));
app = React.cloneElement(app, {repository});
const wrapper = mount(app);
await assert.async.lengthOf(wrapper.find(EditorConflictController), 0);
});
});
});