Skip to content

Commit 3d55fde

Browse files
committed
Update the test for the no token scenario
1 parent c4c6454 commit 3d55fde

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

test/GitHubInfo.spec.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ describe('GitHubInfo', () => {
2020
assert.deepEqual(repo, 'github-release-notes', 'Get the repository name from repo\'s folder');
2121
});
2222

23-
githubInfo.token.then(({ token }) => {
24-
assert.isOk(token);
25-
});
23+
if (process.env.GREN_GITHUB_TOKEN) {
24+
githubInfo.token.then(({ token }) => {
25+
assert.isOk(token);
26+
});
27+
}
2628

2729
githubInfo.options.then(options => {
2830
assert.isOk(options[0].repo);
2931
assert.isOk(options[0].username);
30-
assert.isOk(options[1].token);
32+
33+
if (process.env.GREN_GITHUB_TOKEN) {
34+
assert.isOk(options[1].token);
35+
}
3136
});
3237

3338
});

test/Gren.spec.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@ import fs from 'fs';
44
import Gren from '../lib/src/Gren.js';
55
import { requireConfig } from '../lib/src/_utils.js';
66

7+
const TOKEN = process.env.GREN_GITHUB_TOKEN;
8+
9+
if (!TOKEN) {
10+
console.log(chalk.blue('Token not present, skipping Gren tests.'))
11+
describe = describe.skip
12+
}
13+
714
describe('Gren', () => {
815
const gren = new Gren({
9-
token: process.env.GREN_GITHUB_TOKEN,
16+
token: TOKEN,
1017
username: 'github-tools',
1118
repo: 'github-release-notes'
1219
});
1320

21+
it('Should throw an error', () => {
22+
process.env.GREN_GITHUB_TOKEN = null;
23+
24+
const gren = () => new Gren();
25+
assert.throws(gren, chalk.red('You must provide the TOKEN'), 'No token passed');
26+
});
27+
1428
it('Should generate the options', () => {
1529
assert.isOk(gren.options, 'The options exist');
1630
});

0 commit comments

Comments
 (0)