function expectVersionMetrics(metrics) { expect(metrics).toHaveLength(1); expect(metrics[0].help).toEqual('Node.js version info.'); expect(metrics[0].type).toEqual('gauge'); expect(metrics[0].name).toEqual('nodejs_version_info'); expect(metrics[0].values[0].labels.version).toEqual(nodeVersion); expect(metrics[0].values[0].labels.major).toEqual(versionSegments[0]); expect(metrics[0].values[0].labels.minor).toEqual(versionSegments[1]); expect(metrics[0].values[0].labels.patch).toEqual(versionSegments[2]); }
test("cli.help", t => { const out = log(cli.help) t.ok(out.length, "shows Taskr help") t.true(/Usage/gm.test(out), "includes `Usage` section") t.true(/Options/gm.test(out), "includes `Options` section") t.true(/Examples/gm.test(out), "includes `Examples` section") t.end() })
Object.entries(commands) .map( ([command, { help }]) => endent` ${command} ${endent(help(info))} ` ) .join('\n')
lab.test('it handles no validation errors', (done) => { const result = ParseValidation(); Code.expect(result.error).to.not.exist(); Code.expect(result.hasError).to.be.an.object(); Code.expect(result.hasError).to.have.length(0); Code.expect(result.help).to.be.an.object(); Code.expect(result.help).to.have.length(0); done(); });
const isRequestingTicketSupportConfiguration = ( state ) => { return state.help?.ticket?.isRequesting; }
/** * Returns an array of course objects. * * * @param {object} state Global state tree * @returns {Array} Course objects */ export function getHelpCourses( state ) { return state.help.courses.items; }
Object.keys(definitions).reduce((program, opt) => { if (typeof definitions[opt] == 'object') { const additionalOptions = definitions[opt]; if (additionalOptions.required === true) { return program.option(`--${opt} <${opt}>`, additionalOptions.help, additionalOptions.action); } else { return program.option(`--${opt} [${opt}]`, additionalOptions.help, additionalOptions.action); } } return program.option(`--${opt} [${opt}]`); }, this);
async get() { if (this.collect) { const v = this.collect(); if (v instanceof Promise) await v; } return { help: this.help, name: this.name, type, values: Object.values(this.hashMap), aggregator: this.aggregator, }; }
lab.test('it handles validation errors without keys (error key)', (done) => { const data = { validation: {}, error: 'something else happened' }; const result = ParseValidation(data); Code.expect(result.error).to.equal('something else happened'); Code.expect(result.hasError).to.be.an.object(); Code.expect(Object.keys(result.hasError).length).to.equal(0); Code.expect(result.help).to.be.an.object(); Code.expect(Object.keys(result.help).length).to.equal(0); done(); });
/** * Returns a parsed array of CLI arguments and options * * @since 3.0.0 * @alias lando.cli.argv * @return {Object} Yarg parsed options * @example * const argv = lando.cli.argv(); * @todo make this static and then fix all call sites */ argv() { return require('yargs').help(false).version(false).argv; }
test("cli.help", t => { const out = log(cli.help) t.ok(out.length, "shows Taskr help") t.true(/Usage/gm.test(out), "includes `Usage` section") t.true(/Options/gm.test(out), "includes `Options` section") t.true(/Examples/gm.test(out), "includes `Examples` section") t.end() })
Object.entries(commands) .map( ([command, { help }]) => endent` ${command} ${endent(help(info))} ` ) .join('\n')
async get() { if (this.collect) { const v = this.collect(); if (v instanceof Promise) await v; } return { help: this.help, name: this.name, type, values: Object.values(this.hashMap), aggregator: this.aggregator, }; }
lab.test('it handles validation errors without keys (message key)', (done) => { const data = { validation: {}, message: 'something else happened' }; const result = ParseValidation(data); Code.expect(result.error).to.equal('something else happened'); Code.expect(result.hasError).to.be.an.object(); Code.expect(Object.keys(result.hasError).length).to.equal(0); Code.expect(result.help).to.be.an.object(); Code.expect(Object.keys(result.help).length).to.equal(0); done(); });