renovate/test/config/cli.spec.js
Rhys Arkins 07ad13337b Add GitHub App support (#230)
* Add jsonwebtoken

* Add githubApp option

* Add id and key configs

* Add integer parsing to cli and env

* Remove boolean app enablement

* Drop got

* Add API functions for GitHub Apps

* debug not verbose in api

* Add GitHub App Helper

* Update redact function

* Add GitHub app logic

* Update logging

* Fix lint

* getInstallations tests

* getInstallationToken tests

* getInstallationRepositories tests

* Refactor ghGot structure

* Add github app tests

* Add config tests

* update lockfile
2017-06-02 22:06:15 +02:00

73 lines
2.3 KiB
JavaScript

const cli = require('../../lib/config/cli.js');
const getArgv = require('../_fixtures/config/argv');
describe('config/cli', () => {
let argv;
beforeEach(() => {
argv = getArgv();
});
describe('.getCliName(definition)', () => {
it('generates CLI value', () => {
const option = {
name: 'oneTwoThree',
};
cli.getCliName(option).should.eql('--one-two-three');
});
it('generates returns empty if CLI false', () => {
const option = {
name: 'oneTwoThree',
cli: false,
};
cli.getCliName(option).should.eql('');
});
});
describe('.getConfig(argv)', () => {
it('returns empty argv', () => {
cli.getConfig(argv).should.eql({});
});
it('supports boolean no value', () => {
argv.push('--recreate-closed');
cli.getConfig(argv).should.eql({ recreateClosed: true });
argv = argv.slice(0, -1);
});
it('supports boolean space true', () => {
argv.push('--recreate-closed');
argv.push('true');
cli.getConfig(argv).should.eql({ recreateClosed: true });
});
it('supports boolean space false', () => {
argv.push('--recreate-closed');
argv.push('false');
cli.getConfig(argv).should.eql({ recreateClosed: false });
});
it('supports boolean equals true', () => {
argv.push('--recreate-closed=true');
cli.getConfig(argv).should.eql({ recreateClosed: true });
});
it('supports boolean equals false', () => {
argv.push('--recreate-closed=false');
cli.getConfig(argv).should.eql({ recreateClosed: false });
});
it('supports list single', () => {
argv.push('--labels=a');
cli.getConfig(argv).should.eql({ labels: ['a'] });
});
it('supports list multiple', () => {
argv.push('--labels=a,b,c');
cli.getConfig(argv).should.eql({ labels: ['a', 'b', 'c'] });
});
it('supports string', () => {
argv.push('--token=a');
cli.getConfig(argv).should.eql({ token: 'a' });
});
it('supports integer', () => {
argv.push('--github-app-id=5');
cli.getConfig(argv).should.eql({ githubAppId: 5 });
});
it('supports repositories', () => {
argv.push('foo');
argv.push('bar');
cli.getConfig(argv).should.eql({ repositories: ['foo', 'bar'] });
});
});
});