Skip to content

Commit

Permalink
Update the test for the no token scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcanessa committed Oct 12, 2017
1 parent c4c6454 commit 3d55fde
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 9 additions & 4 deletions test/GitHubInfo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ describe('GitHubInfo', () => {
assert.deepEqual(repo, 'github-release-notes', 'Get the repository name from repo\'s folder');
});

githubInfo.token.then(({ token }) => {
assert.isOk(token);
});
if (process.env.GREN_GITHUB_TOKEN) {
githubInfo.token.then(({ token }) => {
assert.isOk(token);
});
}

githubInfo.options.then(options => {
assert.isOk(options[0].repo);
assert.isOk(options[0].username);
assert.isOk(options[1].token);

if (process.env.GREN_GITHUB_TOKEN) {
assert.isOk(options[1].token);
}
});

});
Expand Down
16 changes: 15 additions & 1 deletion test/Gren.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ import fs from 'fs';
import Gren from '../lib/src/Gren.js';
import { requireConfig } from '../lib/src/_utils.js';

const TOKEN = process.env.GREN_GITHUB_TOKEN;

if (!TOKEN) {
console.log(chalk.blue('Token not present, skipping Gren tests.'))
describe = describe.skip
}

describe('Gren', () => {
const gren = new Gren({
token: process.env.GREN_GITHUB_TOKEN,
token: TOKEN,
username: 'github-tools',
repo: 'github-release-notes'
});

it('Should throw an error', () => {
process.env.GREN_GITHUB_TOKEN = null;

const gren = () => new Gren();
assert.throws(gren, chalk.red('You must provide the TOKEN'), 'No token passed');
});

it('Should generate the options', () => {
assert.isOk(gren.options, 'The options exist');
});
Expand Down

0 comments on commit 3d55fde

Please sign in to comment.