|
1 |
| -/* global describe: false, it: false, expect: false */ |
| 1 | +/* global describe: false, beforeEach: false, afterEach: false, it: false, expect: false */ |
2 | 2 |
|
3 | 3 | 'use strict';
|
4 | 4 |
|
@@ -44,4 +44,65 @@ describe('changelog.js', function() {
|
44 | 44 | expect(msg.breaking).toEqual(' first breaking change\nsomething else\nanother line with more info\n');
|
45 | 45 | });
|
46 | 46 | });
|
| 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 | + }); |
47 | 108 | });
|
0 commit comments