forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-dialog-view.test.js
73 lines (62 loc) · 2.63 KB
/
create-dialog-view.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
import React from 'react';
import {shallow} from 'enzyme';
import {TextBuffer} from 'atom';
import CreateDialogView from '../../lib/views/create-dialog-view';
import RepositoryHomeSelectionView from '../../lib/views/repository-home-selection-view';
import {dialogRequests} from '../../lib/controllers/dialogs-controller';
describe('CreateDialogView', function() {
let atomEnv;
beforeEach(function() {
atomEnv = global.buildAtomEnvironment();
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(override = {}) {
return (
<CreateDialogView
request={dialogRequests.create()}
isLoading={false}
inProgress={false}
selectedOwnerID="user-id"
repoName={new TextBuffer()}
selectedVisibility="PUBLIC"
localPath={new TextBuffer()}
sourceRemoteName={new TextBuffer()}
selectedProtocol="https"
didChangeOwnerID={() => {}}
didChangeVisibility={() => {}}
didChangeProtocol={() => {}}
acceptEnabled={true}
accept={() => {}}
currentWindow={atomEnv.getCurrentWindow()}
workspace={atomEnv.workspace}
commands={atomEnv.commands}
config={atomEnv.config}
{...override}
/>
);
}
it('renders in a loading state when no relay data is available', function() {
const wrapper = shallow(buildApp({user: null, isLoading: true}));
const homeView = wrapper.find(RepositoryHomeSelectionView);
assert.isNull(homeView.prop('user'));
assert.isTrue(homeView.prop('isLoading'));
});
it('customizes dialog text in create mode', function() {
const createRequest = dialogRequests.create();
const wrapper = shallow(buildApp({request: createRequest}));
assert.include(wrapper.find('.github-Create-header').text(), 'Create GitHub repository');
assert.isFalse(wrapper.find('DirectorySelect').prop('disabled'));
assert.strictEqual(wrapper.find('DialogView').prop('acceptText'), 'Create');
});
it('customizes dialog text and disables local directory controls in publish mode', function() {
const publishRequest = dialogRequests.publish({localDir: '/local/directory'});
const localPath = new TextBuffer({text: '/local/directory'});
const wrapper = shallow(buildApp({request: publishRequest, localPath}));
assert.include(wrapper.find('.github-Create-header').text(), 'Publish GitHub repository');
assert.isTrue(wrapper.find('DirectorySelect').prop('disabled'));
assert.strictEqual(wrapper.find('DirectorySelect').prop('buffer').getText(), '/local/directory');
assert.strictEqual(wrapper.find('DialogView').prop('acceptText'), 'Publish');
});
});