| 341 | } |
| 342 | |
| 343 | export 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 | |
| 369 | export function randomAsyncSystemConfig( |
| 370 | configOptions: Array<keyof AsyncSystemConfig<any, any, any>>, |