test-openapi
Version:
Automated client requests
99 lines (64 loc) • 2.52 kB
JavaScript
require("core-js/modules/es.array.iterator");require("core-js/modules/es.promise");Object.defineProperty(exports,"__esModule",{value:true});exports.addOptions=void 0;var _lodash=require("lodash");
var _check=require("../../../validation/check.js");
var _silent=require("../level/silent.js");
var _normalize=require("../level/normalize.js");
var _common_options_schema=require("./common_options_schema");
var _output=require("./output.js");
const addOptions=async function({reporters,config,context}){
const promises=reporters.map((reporter)=>
addReporterOptions({reporter,config,context}));
const reportersA=await Promise.all(promises);
const reportersB=reportersA.filter(reporter=>reporter!==undefined);
return reportersB;
};exports.addOptions=addOptions;
const addReporterOptions=async function({reporter,config,context}){
const options=getOptions({reporter,config});
validateOptions({reporter,options});
const optionsA=await normalizeOptions({options,reporter});
if((0,_silent.isSilent)({options:optionsA})){
return;
}
const optionsB=transformOptions({reporter,options:optionsA,context});
return{...reporter,options:optionsB};
};
const getOptions=function({
reporter:{name},
config:{report={},report:{[name]:options={}}={}}})
{
const globalOptions=(0,_lodash.pick)(report,Object.keys(_common_options_schema.COMMON_OPTIONS_SCHEMA));
if(options===true){
return globalOptions;
}
const optionsA=(0,_lodash.omitBy)(options,value=>value===undefined);
return{...globalOptions,...optionsA};
};
const validateOptions=function({reporter,reporter:{name},options}){
const schema=getOptionsSchema({reporter});
(0,_check.checkSchema)({
schema,
value:options,
valueProp:`config.report.${name}`,
message:`Configuration for '${name}' reporter is invalid`,
props:{module:`reporter-${name}`}});
};
const getOptionsSchema=function({reporter:{config}}){
const properties={..._common_options_schema.COMMON_OPTIONS_SCHEMA,...config};
return{type:"object",properties,additionalProperties:false};
};
const normalizeOptions=async function({options,reporter}){
const level=(0,_normalize.normalizeLevel)({options,reporter});
const output=await(0,_output.normalizeOutput)({options,reporter});
return{...options,level,output};
};
const transformOptions=function({
reporter:{options:reporterOptions},
options,
context})
{
if(reporterOptions===undefined){
return options;
}
const optionsA=reporterOptions({...context,options});
return{...optionsA,...options};
};
//# sourceMappingURL=options.js.map
;