Skip to content

Commit f6240b1

Browse files
donmahallemalexcanessa
authored andcommitted
* fix issue github-tools#255 * added test to _getReleaseBlocks to handle just one tag too
1 parent 617cb77 commit f6240b1

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

lib/src/Gren.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ class Gren {
11271127
this._validateRequiredTagsExists(tags, this.options.tags);
11281128

11291129
const releaseDates = this._sortReleasesByDate(await Promise.all(this._getTagDates(tags)));
1130-
const selectedTags = (this._getSelectedTags(releaseDates) || [releaseDates[0], releaseDates[1]]);
1130+
const selectedTags = (this._getSelectedTags(releaseDates) || (releaseDates.length > 1 ? [releaseDates[0], releaseDates[1]] : releaseDates));
11311131

11321132
loaded(`Tags found: ${selectedTags.map(({ name }) => name).join(', ')}`);
11331133

test/Gren.spec.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -610,17 +610,32 @@ describe('Gren', () => {
610610
});
611611
});
612612

613-
it('_getReleaseBlocks', done => {
614-
gren.options.tags = ['0.12.0', '0.11.0'];
615-
gren._getReleaseBlocks()
616-
.then(releaseBlocks => {
617-
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
618-
releaseBlocks.forEach(block => {
619-
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
620-
});
621-
done();
622-
})
623-
.catch(err => done(err));
624-
}).timeout(10000);
613+
describe('_getReleaseBlocks', () => {
614+
it('more than one tag', done => {
615+
gren.options.tags = ['0.12.0', '0.11.0'];
616+
gren._getReleaseBlocks()
617+
.then(releaseBlocks => {
618+
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
619+
releaseBlocks.forEach(block => {
620+
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
621+
});
622+
done();
623+
})
624+
.catch(err => done(err));
625+
}).timeout(10000);
626+
627+
it('just one tag', done => {
628+
gren.options.tags = ['0.11.0'];
629+
gren._getReleaseBlocks()
630+
.then(releaseBlocks => {
631+
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
632+
releaseBlocks.forEach(block => {
633+
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
634+
});
635+
done();
636+
})
637+
.catch(err => done(err));
638+
}).timeout(10000);
639+
});
625640
});
626641
});

0 commit comments

Comments
 (0)