-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.js
148 lines (128 loc) · 4.75 KB
/
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
'use strict';
var child = require('child_process');
var conventionalChangelogCore = require('conventional-changelog-core');
var preset = require('./');
var expect = require('chai').expect;
var gitDummyCommit = require('git-dummy-commit');
var shell = require('shelljs');
var through = require('through2');
describe('angular preset', function() {
before(function(done) {
shell.config.silent = true;
shell.rm('-rf', 'tmp');
shell.mkdir('tmp');
shell.cd('tmp');
shell.mkdir('git-templates');
shell.exec('git init --template=./git-templates');
gitDummyCommit('chore: first commit');
// fix this until https:/arturadib/shelljs/issues/175 is solved
child.exec('git commit -m"feat: amazing new module\n\nBREAKING CHANGE: Not backward compatible." --allow-empty', function() {
gitDummyCommit(['fix(compile): avoid a bug', 'BREAKING CHANGE: The Change is huge.']);
gitDummyCommit('perf(ngOptions): make it faster');
gitDummyCommit('revert(ngOptions): make it faster');
gitDummyCommit('fix(*): oops');
done();
});
});
it('should work if there is no semver tag', function(done) {
conventionalChangelogCore({
config: preset
})
.on('error', function(err) {
done(err);
})
.pipe(through(function(chunk) {
chunk = chunk.toString();
expect(chunk).to.include('amazing new module');
expect(chunk).to.include('avoid a bug');
expect(chunk).to.include('make it faster');
expect(chunk).to.include('Not backward compatible.');
expect(chunk).to.include('compile: The Change is huge.');
expect(chunk).to.include('Features');
expect(chunk).to.include('Bug Fixes');
expect(chunk).to.include('Performance Improvements');
expect(chunk).to.include('Reverts');
expect(chunk).to.include('BREAKING CHANGES');
expect(chunk).to.not.include('first commit');
expect(chunk).to.not.include('feat');
expect(chunk).to.not.include('fix');
expect(chunk).to.not.include('perf');
expect(chunk).to.not.include('revert');
expect(chunk).to.not.include('***:**');
expect(chunk).to.not.include(': Not backward compatible.');
done();
}));
});
it('should replace #[0-9]+ with GitHub issue URL', function(done) {
gitDummyCommit(['feat(awesome): addresses the issue brought up in #133']);
conventionalChangelogCore({
config: preset
})
.on('error', function(err) {
done(err);
})
.pipe(through(function(chunk) {
chunk = chunk.toString();
expect(chunk).to.include('[#133](https:/bcoe/conventional-changelog-standard/issues/133)');
done();
}));
});
it('should replace @username with GitHub user URL', function(done) {
gitDummyCommit(['feat(awesome): issue brought up by @bcoe! on Friday']);
conventionalChangelogCore({
config: preset
})
.on('error', function(err) {
done(err);
})
.pipe(through(function(chunk) {
chunk = chunk.toString();
expect(chunk).to.include('[@bcoe](https:/bcoe)');
done();
}));
});
it('should not discard commit if there is BREAKING CHANGE', function(done) {
gitDummyCommit(['docs(readme): make it clear', 'BREAKING CHANGE: The Change is huge.']);
gitDummyCommit(['style(whitespace): make it easier to read', 'BREAKING CHANGE: The Change is huge.']);
gitDummyCommit(['refactor(code): change a lot of code', 'BREAKING CHANGE: The Change is huge.']);
gitDummyCommit(['test(*): more tests', 'BREAKING CHANGE: The Change is huge.']);
gitDummyCommit(['chore(deps): bump', 'BREAKING CHANGE: The Change is huge.']);
conventionalChangelogCore({
config: preset
})
.on('error', function(err) {
done(err);
})
.pipe(through(function(chunk) {
chunk = chunk.toString();
expect(chunk).to.include('Documentation');
expect(chunk).to.include('Styles');
expect(chunk).to.include('Code Refactoring');
expect(chunk).to.include('Tests');
expect(chunk).to.include('Chores');
done();
}));
});
it('should work if there is a semver tag', function(done) {
var i = 0;
shell.exec('git tag v1.0.0');
gitDummyCommit('feat: some more features');
conventionalChangelogCore({
config: preset,
outputUnreleased: true
})
.on('error', function(err) {
done(err);
})
.pipe(through(function(chunk, enc, cb) {
chunk = chunk.toString();
expect(chunk).to.include('some more features');
expect(chunk).to.not.include('BREAKING');
i++;
cb();
}, function() {
expect(i).to.equal(1);
done();
}));
});
});