( configOptions: Array<keyof AsyncSystemConfig<any, any, any>>, unitsConfigOptions: Array<keyof UnitConfig<any>>, validness = 0.7, nestingLvl = 1 )
| 367 | } |
| 368 | |
| 369 | export function randomAsyncSystemConfig( |
| 370 | configOptions: Array<keyof AsyncSystemConfig<any, any, any>>, |
| 371 | unitsConfigOptions: Array<keyof UnitConfig<any>>, |
| 372 | validness = 0.7, |
| 373 | nestingLvl = 1 |
| 374 | ): AsyncSystemConfig<any, any, any> { |
| 375 | return Faker.helpers |
| 376 | .shuffle(configOptions) // shuffle the options to pick random options every time |
| 377 | .slice(0, randomNumber(0, configOptions.length - 1)) // pick some random options |
| 378 | .reduce((reduced, option) => { |
| 379 | // generate a config object from options |
| 380 | switch (option) { |
| 381 | case 'initialValue': |
| 382 | reduced[option] = randomAsyncSystemInitialValue(validness, nestingLvl); |
| 383 | break; |
| 384 | case 'UNITS': |
| 385 | case 'QUERY_UNIT': |
| 386 | case 'DATA_UNIT': |
| 387 | case 'ERROR_UNIT': |
| 388 | reduced[option] = somewhatValidConfig( |
| 389 | unitsConfigOptions, |
| 390 | GenericUnit, |
| 391 | validness, |
| 392 | nestingLvl |
| 393 | ); |
| 394 | break; |
| 395 | case 'PENDING_UNIT': |
| 396 | reduced[option] = somewhatValidConfig( |
| 397 | unitsConfigOptions, |
| 398 | BoolUnit, |
| 399 | validness, |
| 400 | nestingLvl |
| 401 | ); |
| 402 | break; |
| 403 | default: |
| 404 | reduced[option] = RANDOM_CONFIG_OPTIONS_VALUE_PRODUCERS[option](validness, nestingLvl); |
| 405 | } |
| 406 | |
| 407 | return reduced; |
| 408 | }, {}); |
| 409 | } |
| 410 | |
| 411 | export function randomInitialValue( |
| 412 | unit: (new () => UnitBase<any> | Action<any>) | UnitBase<any> | Action<any>, |
no test coverage detected