Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix issue github-tools#255

* added test to _getReleaseBlocks to handle just one tag too
  • Loading branch information
donmahallem authored and alexcanessa committed Jan 9, 2020
1 parent 617cb77 commit f6240b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/src/Gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ class Gren {
this._validateRequiredTagsExists(tags, this.options.tags);

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

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

Expand Down
39 changes: 27 additions & 12 deletions test/Gren.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,17 +610,32 @@ describe('Gren', () => {
});
});

it('_getReleaseBlocks', done => {
gren.options.tags = ['0.12.0', '0.11.0'];
gren._getReleaseBlocks()
.then(releaseBlocks => {
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
releaseBlocks.forEach(block => {
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
});
done();
})
.catch(err => done(err));
}).timeout(10000);
describe('_getReleaseBlocks', () => {
it('more than one tag', done => {
gren.options.tags = ['0.12.0', '0.11.0'];
gren._getReleaseBlocks()
.then(releaseBlocks => {
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
releaseBlocks.forEach(block => {
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
});
done();
})
.catch(err => done(err));
}).timeout(10000);

it('just one tag', done => {
gren.options.tags = ['0.11.0'];
gren._getReleaseBlocks()
.then(releaseBlocks => {
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
releaseBlocks.forEach(block => {
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
});
done();
})
.catch(err => done(err));
}).timeout(10000);
});
});
});

0 comments on commit f6240b1

Please sign in to comment.