Skip to content

Commit 4cd37e9

Browse files
committed
Adjust tests to support new features
1 parent c2d01f4 commit 4cd37e9

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

lib/src/Gren.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ class Gren {
11141114

11151115
const tags = await this._getAllTags(releases.length ? releases : false);
11161116
const branchCommitShas = (await this._getAllCommitsForBranch(this.options.head)).map(commit => commit.sha);
1117-
const filteredTags = tags.filter(tag => branchCommitShas.includes(tag.commit.sha));
1117+
const filteredTags = tags.filter(tag => branchCommitShas.includes(tag.commit?.sha || tag.tag.commit?.sha));
11181118

11191119
this._validateRequiredTagsExists(filteredTags, this.options.tags);
11201120

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"scripts": {
77
"changelog": "node bin/gren.js changelog --override --generate --head master",
88
"build": "gulp build",
9+
"prerelease": "git clean -xfd && npm ci && npm test && npm run build",
10+
"release": "release-it",
911
"start": "node github-release-notes.js",
1012
"test": "./node_modules/.bin/nyc mocha --reporter=nyan --require @babel/register",
1113
"coverage": "nyc --reporter=lcov --reporter=text mocha --require @babel/register",

test/Gren.spec.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Gren', () => {
7272
});
7373
});
7474

75-
it('Should return ranges of Objects', () => {
75+
it('Should return ranges of Objects', async () => {
7676
const rangedBlocks = [
7777
[
7878
{
@@ -100,10 +100,10 @@ describe('Gren', () => {
100100
]
101101
];
102102

103-
assert.deepEqual(gren._createReleaseRanges(blocks), rangedBlocks, 'Given release blocks');
104-
103+
assert.deepEqual(await gren._createReleaseRanges(blocks), rangedBlocks, 'Given release blocks');
104+
105105
gren.options.tags = 'all';
106-
assert.deepEqual(gren._createReleaseRanges(blocks), rangedBlocks.concat([[
106+
assert.deepEqual(await gren._createReleaseRanges(blocks), rangedBlocks.concat([[
107107
{
108108
date: '2016-09-01T23:00:00.000Z'
109109
},
@@ -639,32 +639,28 @@ describe('Gren', () => {
639639
});
640640

641641
describe('_getReleaseBlocks', () => {
642-
it('more than one tag', done => {
642+
it('more than one tag', async () => {
643643
gren.options.tags = ['0.17.2', '0.17.1'];
644644
gren.options.dataSource = 'commits';
645-
gren._getReleaseBlocks()
645+
await gren._getReleaseBlocks()
646646
.then(releaseBlocks => {
647647
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
648648
releaseBlocks.forEach(block => {
649649
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
650650
});
651-
done();
652651
})
653-
.catch(err => done(err));
654652
}).timeout(10000);
655653

656-
it('just one tag', done => {
654+
it('just one tag', async () => {
657655
gren.options.tags = ['0.17.2'];
658656
gren.options.dataSource = 'commits';
659-
gren._getReleaseBlocks()
657+
await gren._getReleaseBlocks()
660658
.then(releaseBlocks => {
661659
assert.isArray(releaseBlocks, 'The releaseBlocks is an Array');
662660
releaseBlocks.forEach(block => {
663661
assert.hasAllKeys(block, ['id', 'release', 'name', 'published_at', 'body']);
664662
});
665-
done();
666663
})
667-
.catch(err => done(err));
668664
}).timeout(10000);
669665
});
670666
});

0 commit comments

Comments
 (0)