From 609afabe9ff672a3662c51c70c8eeb0c1331a984 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Sat, 6 Feb 2016 22:44:07 +1100 Subject: [PATCH] test(generateOn): add more --- test/index.spec.js | 74 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/test/index.spec.js b/test/index.spec.js index 2101214..73b93c7 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -353,7 +353,6 @@ describe('conventionalChangelogWriter', function() { footer: null, notes: [], references: [], - version: '3.0.1', committerDate: '2015-04-07 15:01:30 +1000' }); upstream.write({ @@ -376,16 +375,28 @@ describe('conventionalChangelogWriter', function() { if (i === 0) { expect(chunk).to.include('\n# (' + today); + expect(chunk).to.not.include('\n## 1.0.1 (2015-04-07)'); } else if (i === 1) { expect(chunk).to.include(''); + expect(chunk).to.include('feat(scope): broadcast $destroy event on scope destruction'); + expect(chunk).to.not.include(''); + } else if (i === 2) { + expect(chunk).to.include(''); + expect(chunk).to.include('fix(ng-list): Allow custom separator'); + expect(chunk).to.include('perf(template): tweak'); + } else if (i === 3) { + expect(chunk).to.include(''); + expect(chunk).to.include('refactor(name): rename this module to conventional-changelog-writer'); + + expect(chunk).to.not.include('perf(template): tweak'); } i++; cb(null); }, function() { - expect(i).to.equal(5); + expect(i).to.equal(4); done(); })); }); @@ -568,7 +579,45 @@ describe('conventionalChangelogWriter', function() { it('should generate on `\'version\'` if it\'s a valid semver', function(done) { var i = 0; - getStream() + var upstream = through.obj(); + upstream.write({ + header: 'feat(scope): broadcast $destroy event on scope destruction', + body: null, + footer: null, + notes: [], + references: [], + version: '1.0.1', + committerDate: '2015-04-07 14:17:05 +1000' + }); + upstream.write({ + header: 'fix(ng-list): Allow custom separator', + body: 'bla bla bla', + footer: null, + notes: [], + references: [], + version: '2.0.1', + committerDate: '2015-04-07 15:00:44 +1000' + }); + upstream.write({ + header: 'perf(template): tweak', + body: 'My body.', + footer: null, + notes: [], + references: [], + committerDate: '2015-04-07 15:01:30 +1000' + }); + upstream.write({ + header: 'refactor(name): rename this module to conventional-changelog-writer', + body: null, + footer: null, + notes: [], + references: [], + version: '4.0.1', + committerDate: '2015-04-08 09:43:59 +1000' + }); + upstream.end(); + + upstream .pipe(conventionalChangelogWriter({}, { reverse: true })) @@ -576,27 +625,30 @@ describe('conventionalChangelogWriter', function() { chunk = chunk.toString(); if (i === 0) { - expect(chunk).to.include('\n## 1.0.1 (2015-04-07)'); + expect(chunk).to.include('\n## 1.0.1 (2015-04-07'); expect(chunk).to.include('feat(scope): '); - expect(chunk).to.include('fix(ng-list): '); expect(chunk).to.not.include(''); expect(chunk).to.not.include('perf(template): '); expect(chunk).to.not.include('refactor(name): '); - } else { - expect(chunk).to.include('\n# (' + today); - expect(chunk).to.include('perf(template): '); - expect(chunk).to.include('refactor(name): '); + } else if (i === 1) { + expect(chunk).to.include('\n## 2.0.1 (2015-04-07'); + expect(chunk).to.include('fix(ng-list): '); expect(chunk).to.not.include(''); expect(chunk).to.not.include('feat(scope): '); - expect(chunk).to.not.include('fix(ng-list): '); + } else if (i === 2) { + expect(chunk).to.include('\n#'); + expect(chunk).to.include('perf(template): '); + expect(chunk).to.include('refactor(name): '); + } else if (i === 3) { + expect(chunk).to.include('\n# (' + today); } i++; cb(null); }, function() { - expect(i).to.equal(2); + expect(i).to.equal(4); done(); })); });