|
c5cba6e
gkalpak authored
|
||
| 1 | /* global describe: false, beforeEach: false, afterEach: false, it: false, expect: false */ | |
|
36831ec
mzgol authored
|
||
| 2 | ||
| 3 | 'use strict'; | |
| 4 | ||
|
4557881
vojtajina authored
|
||
| 5 | describe('changelog.js', function() { | |
| 6 | var ch = require('./changelog'); | |
| 7 | ||
| 8 | describe('parseRawCommit', function() { | |
| 9 | it('should parse raw commit', function() { | |
| 10 | var msg = ch.parseRawCommit( | |
| 11 | '9b1aff905b638aa274a5fc8f88662df446d374bd\n' + | |
| 12 | 'feat(scope): broadcast $destroy event on scope destruction\n' + | |
| 13 | 'perf testing shows that in chrome this change adds 5-15% overhead\n' + | |
| 14 | 'when destroying 10k nested scopes where each scope has a $destroy listener\n'); | |
| 15 | ||
| 16 | expect(msg.type).toBe('feat'); | |
| 17 | expect(msg.hash).toBe('9b1aff905b638aa274a5fc8f88662df446d374bd'); | |
| 18 | expect(msg.subject).toBe('broadcast $destroy event on scope destruction'); | |
| 19 | expect(msg.body).toBe('perf testing shows that in chrome this change adds 5-15% overhead\n' + | |
|
36831ec
mzgol authored
|
||
| 20 | 'when destroying 10k nested scopes where each scope has a $destroy listener\n'); | |
|
4557881
vojtajina authored
|
||
| 21 | expect(msg.component).toBe('scope'); | |
| 22 | }); | |
| 23 | ||
| 24 | ||
| 25 | it('should parse closed issues', function() { | |
| 26 | var msg = ch.parseRawCommit( | |
| 27 | '13f31602f396bc269076ab4d389cfd8ca94b20ba\n' + | |
| 28 | 'feat(ng-list): Allow custom separator\n' + | |
| 29 | 'bla bla bla\n\n' + | |
| 30 | 'Closes #123\nCloses #25\n'); | |
| 31 | ||
| 32 | expect(msg.closes).toEqual([123, 25]); | |
| 33 | }); | |
| 34 | ||
| 35 | ||
| 36 | it('should parse breaking changes', function() { | |
| 37 | var msg = ch.parseRawCommit( | |
| 38 | '13f31602f396bc269076ab4d389cfd8ca94b20ba\n' + | |
| 39 | 'feat(ng-list): Allow custom separator\n' + | |
| 40 | 'bla bla bla\n\n' + | |
|
07a58dd
IgorMinar authored
|
||
| 41 | 'BREAKING CHANGE: first breaking change\nsomething else\n' + | |
| 42 | 'another line with more info\n'); | |
|
4557881
vojtajina authored
|
||
| 43 | ||
|
07a58dd
IgorMinar authored
|
||
| 44 | expect(msg.breaking).toEqual(' first breaking change\nsomething else\nanother line with more info\n'); | |
|
4557881
vojtajina authored
|
||
| 45 | }); | |
| 46 | }); | |
|
c5cba6e
gkalpak authored
|
||
| 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 | }); | |
|
4557881
vojtajina authored
|
||
| 108 | }); |