forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-tab-view.test.js
More file actions
66 lines (55 loc) · 2.36 KB
/
github-tab-view.test.js
File metadata and controls
66 lines (55 loc) · 2.36 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
import React from 'react';
import {shallow} from 'enzyme';
import {gitHubTabViewProps} from '../fixtures/props/github-tab-props';
import Repository from '../../lib/models/repository';
import Remote, {nullRemote} from '../../lib/models/remote';
import RemoteSet from '../../lib/models/remote-set';
import Branch from '../../lib/models/branch';
import GitHubTabView from '../../lib/views/github-tab-view';
describe('GitHubTabView', function() {
let atomEnv;
beforeEach(function() {
atomEnv = global.buildAtomEnvironment();
});
afterEach(function() {
atomEnv.destroy();
});
function buildApp(overrideProps = {}) {
const props = gitHubTabViewProps(atomEnv, overrideProps.repository || Repository.absent(), overrideProps);
return <GitHubTabView {...props} />;
}
it('renders a LoadingView if data is still loading', function() {
const wrapper = shallow(buildApp({isLoading: true}));
assert.isTrue(wrapper.find('LoadingView').exists());
});
it('renders a RemoteContainer if a remote has been chosen', function() {
const currentRemote = new Remote('aaa', 'git@github.com:aaa/bbb.git');
const currentBranch = new Branch('bbb');
const handlePushBranch = sinon.spy();
const wrapper = shallow(buildApp({currentRemote, currentBranch, handlePushBranch}));
const container = wrapper.find('RemoteContainer');
assert.isTrue(container.exists());
assert.strictEqual(container.prop('remote'), currentRemote);
container.prop('onPushBranch')();
assert.isTrue(handlePushBranch.calledWith(currentBranch, currentRemote));
});
it('renders a RemoteSelectorView when many remote choices are available', function() {
const remotes = new RemoteSet();
const handleRemoteSelect = sinon.spy();
const wrapper = shallow(buildApp({
remotes,
currentRemote: nullRemote,
manyRemotesAvailable: true,
handleRemoteSelect,
}));
const selector = wrapper.find('RemoteSelectorView');
assert.isTrue(selector.exists());
assert.strictEqual(selector.prop('remotes'), remotes);
selector.prop('selectRemote')();
assert.isTrue(handleRemoteSelect.called);
});
it('renders a static message when no remotes are available', function() {
const wrapper = shallow(buildApp({currentRemote: nullRemote, manyRemotesAvailable: false}));
assert.isTrue(wrapper.find('.github-GitHub-noRemotes').exists());
});
});