-
Notifications
You must be signed in to change notification settings - Fork 554
/
Copy pathcli.js
66 lines (52 loc) · 1.69 KB
/
cli.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
import { expect } from 'chai';
import proxyquire from 'proxyquire';
import sinon from 'sinon';
describe('git-cz', () => {
let bootstrap;
let fakeStrategies, fakeCommitizen;
beforeEach(() => {
fakeStrategies = {
gitCz: sinon.spy()
}
fakeCommitizen = {
configLoader: {
load: sinon.stub()
}
}
bootstrap = proxyquire('../../src/cli/git-cz', {
'./strategies': fakeStrategies,
'../commitizen': fakeCommitizen
}).bootstrap;
});
describe('bootstrap', () => {
describe('when config is provided', () => {
it('passes config to useGitCzStrategy', () => {
const config = sinon.spy();
bootstrap({ config });
expect(fakeStrategies.gitCz.args[0][2]).to.equal(config);
});
});
describe('when config is not provided', () => {
describe('and the config is returned from configLoader.load', () => {
it('uses config from configLoader.load()', () => {
const config = sinon.stub();
fakeCommitizen.configLoader.load.returns(config);
bootstrap({});
expect(fakeStrategies.gitCz.args[0][2]).to.equal(config);
});
});
describe('and the config is not returned from configLoader.load', () => {
it('tells commitizen to use the default adapter', () => {
bootstrap({});
expect(fakeStrategies.gitCz.args[0][2].path).to.equal('cz-conventional-changelog');
});
});
});
describe('when argv is overridden', () => {
it('uses the overridden argv', () => {
bootstrap({}, ['node', 'git-cz', 'index.js']);
expect(fakeStrategies.gitCz.args[0][0][0]).to.equal('index.js');
});
})
});
});