This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 402
/
Copy pathgit-tab-container.test.js
73 lines (56 loc) · 2.66 KB
/
git-tab-container.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 {mount} from 'enzyme';
import GitTabContainer from '../../lib/containers/git-tab-container';
import Repository from '../../lib/models/repository';
import {gitTabContainerProps} from '../fixtures/props/git-tab-props.js';
import {cloneRepository, buildRepository} from '../helpers';
describe('GitTabContainer', function() {
let atomEnv;
beforeEach(function() {
atomEnv = global.buildAtomEnvironment();
});
afterEach(function() {
atomEnv.destroy();
});
describe('while the repository is loading', function() {
let wrapper;
beforeEach(async function() {
const workdirPath = await cloneRepository();
const loadingRepository = new Repository(workdirPath);
const props = gitTabContainerProps(atomEnv, loadingRepository);
wrapper = mount(<GitTabContainer {...props} />);
});
it('passes default repository props', function() {
assert.isFalse(wrapper.find('GitTabController').prop('lastCommit').isPresent());
assert.lengthOf(wrapper.find('GitTabController').prop('recentCommits'), 0);
});
it('sets fetchInProgress to true', function() {
assert.isTrue(wrapper.find('GitTabController').prop('fetchInProgress'));
});
});
describe('when the repository attributes arrive', function() {
let loadedRepository;
beforeEach(async function() {
const workdirPath = await cloneRepository();
loadedRepository = await buildRepository(workdirPath);
});
it('passes them as props', async function() {
const props = gitTabContainerProps(atomEnv, loadedRepository);
const wrapper = mount(<GitTabContainer {...props} />);
await assert.async.isFalse(wrapper.update().find('GitTabController').prop('fetchInProgress'));
const controller = wrapper.find('GitTabController');
assert.strictEqual(controller.prop('lastCommit'), await loadedRepository.getLastCommit());
assert.deepEqual(controller.prop('recentCommits'), await loadedRepository.getRecentCommits({max: 10}));
assert.strictEqual(controller.prop('isMerging'), await loadedRepository.isMerging());
assert.strictEqual(controller.prop('isRebasing'), await loadedRepository.isRebasing());
});
it('passes other props through', async function() {
const extraProp = Symbol('extra');
const props = gitTabContainerProps(atomEnv, loadedRepository, {extraProp});
const wrapper = mount(<GitTabContainer {...props} />);
await assert.async.isFalse(wrapper.update().find('GitTabController').prop('fetchInProgress'));
const controller = wrapper.find('GitTabController');
assert.strictEqual(controller.prop('extraProp'), extraProp);
});
});
});