renovate/test/config/cli.spec.js
Rhys Arkins af75504e20 feat: deprecate github app (#1068)
BREAKING CHANGE: GitHub *App* support code has been removed from within this repository.
2017-11-01 13:13:55 +01:00

69 lines
2.1 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 repositories', () => {
argv.push('foo');
argv.push('bar');
cli.getConfig(argv).should.eql({ repositories: ['foo', 'bar'] });
});
});
});