Skip to content

Commit c5cba6e

Browse files
gkalpakcaitp
authored andcommitted
chore(changelog): add test for addition of trailing newline
Adds tests for the functionality added by angular#9550. Closes angular#10358
1 parent 924d3c6 commit c5cba6e

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

changelog.js

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ var generate = function(version, file) {
202202

203203
// publish for testing
204204
exports.parseRawCommit = parseRawCommit;
205+
exports.printSection = printSection;
205206

206207
// hacky start if not run by jasmine :-D
207208
if (process.argv.join('').indexOf('jasmine-node') === -1) {

changelog.spec.js

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe: false, it: false, expect: false */
1+
/* global describe: false, beforeEach: false, afterEach: false, it: false, expect: false */
22

33
'use strict';
44

@@ -44,4 +44,65 @@ describe('changelog.js', function() {
4444
expect(msg.breaking).toEqual(' first breaking change\nsomething else\nanother line with more info\n');
4545
});
4646
});
47+
48+
describe('printSection', function() {
49+
var output;
50+
var streamMock = {
51+
write: function(str) {
52+
output += str;
53+
}
54+
};
55+
56+
beforeEach(function() {
57+
output = '';
58+
});
59+
60+
it('should add a new line at the end of each breaking change list item ' +
61+
'when there is 1 item per component', function() {
62+
var title = 'test';
63+
var printCommitLinks = false;
64+
65+
var section = {
66+
module1: [{subject: 'breaking change 1'}],
67+
module2: [{subject: 'breaking change 2'}]
68+
};
69+
var expectedOutput =
70+
'\n' + '## test\n\n' +
71+
'- **module1:** breaking change 1\n' +
72+
'- **module2:** breaking change 2\n' +
73+
'\n';
74+
75+
ch.printSection(streamMock, title, section, printCommitLinks);
76+
expect(output).toBe(expectedOutput);
77+
});
78+
79+
it('should add a new line at the end of each breaking change list item ' +
80+
'when there are multiple items per component', function() {
81+
var title = 'test';
82+
var printCommitLinks = false;
83+
84+
var section = {
85+
module1: [
86+
{subject: 'breaking change 1.1'},
87+
{subject: 'breaking change 1.2'}
88+
],
89+
module2: [
90+
{subject: 'breaking change 2.1'},
91+
{subject: 'breaking change 2.2'}
92+
]
93+
};
94+
var expectedOutput =
95+
'\n' + '## test\n\n' +
96+
'- **module1:**\n' +
97+
' - breaking change 1.1\n' +
98+
' - breaking change 1.2\n' +
99+
'- **module2:**\n' +
100+
' - breaking change 2.1\n' +
101+
' - breaking change 2.2\n' +
102+
'\n';
103+
104+
ch.printSection(streamMock, title, section, printCommitLinks);
105+
expect(output).toBe(expectedOutput);
106+
});
107+
});
47108
});

0 commit comments

Comments
 (0)