MCPcopy Create free account
hub / github.com/activejs/activejs / somewhatValidConfig

Function somewhatValidConfig

packages/core/src/tests/utils.ts:343–367  ·  view source on GitHub ↗
(
  configOptions: Array<keyof UnitConfig<any>>,
  o: (new () => UnitBase<any> | Action<any>) | UnitBase<any> | Action<any>,
  validness = 0.7,
  nestingLvl = 1
)

Source from the content-addressed store, hash-verified

341}
342
343export function somewhatValidConfig(
344 configOptions: Array<keyof UnitConfig<any>>,
345 o: (new () => UnitBase<any> | Action<any>) | UnitBase<any> | Action<any>,
346 validness = 0.7,
347 nestingLvl = 1
348): UnitConfig<any> {
349 return (
350 Faker.helpers
351 .shuffle(configOptions) // shuffle the options to pick random options every time
352 .slice(0, randomNumber(0, configOptions.length - 1)) // pick some random options
353 // generate a config object from options
354 .reduce((reduced, option) => {
355 // generate a config object from options
356 switch (option) {
357 case 'initialValue':
358 reduced[option] = randomInitialValue(o, validness, nestingLvl);
359 break;
360 default:
361 reduced[option] = RANDOM_CONFIG_OPTIONS_VALUE_PRODUCERS[option](validness, nestingLvl);
362 }
363
364 return reduced;
365 }, {})
366 );
367}
368
369export function randomAsyncSystemConfig(
370 configOptions: Array<keyof AsyncSystemConfig<any, any, any>>,

Callers 8

createUnitFunction · 0.90
units.spec.tsFile · 0.90
dict-unit.spec.tsFile · 0.90
list-unit.spec.tsFile · 0.90
makeUnitFunction · 0.90
randomAsyncSystemConfigFunction · 0.85

Calls 3

randomNumberFunction · 0.85
randomInitialValueFunction · 0.85
sliceMethod · 0.80

Tested by 2

createUnitFunction · 0.72
makeUnitFunction · 0.72