forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchanged-file-controller.test.js
62 lines (49 loc) · 1.65 KB
/
changed-file-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
import React from 'react';
import {shallow} from 'enzyme';
import ChangedFileController from '../../lib/controllers/changed-file-controller';
import {cloneRepository, buildRepository} from '../helpers';
describe('ChangedFileController', function() {
let atomEnv, repository;
beforeEach(async function() {
atomEnv = global.buildAtomEnvironment();
repository = await buildRepository(await cloneRepository('three-files'));
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(override = {}) {
const props = {
repository,
stagingStatus: 'unstaged',
relPath: 'file.txt',
workspace: atomEnv.workspace,
commands: atomEnv.commands,
keymaps: atomEnv.keymaps,
tooltips: atomEnv.tooltips,
config: atomEnv.config,
multiFilePatch: {
getFilePatches: () => {},
},
destroy: () => {},
undoLastDiscard: () => {},
surfaceFileAtPath: () => {},
...override,
};
return <ChangedFileController {...props} />;
}
it('passes unrecognized props to a MultiFilePatchController', function() {
const extra = Symbol('extra');
const wrapper = shallow(buildApp({extra}));
assert.strictEqual(wrapper.find('MultiFilePatchController').prop('extra'), extra);
});
it('calls surfaceFileAtPath with fixed arguments', function() {
const surfaceFileAtPath = sinon.spy();
const wrapper = shallow(buildApp({
relPath: 'whatever.js',
stagingStatus: 'staged',
surfaceFileAtPath,
}));
wrapper.find('MultiFilePatchController').prop('surface')();
assert.isTrue(surfaceFileAtPath.calledWith('whatever.js', 'staged'));
});
});