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

Function randomValidValue

packages/core/src/tests/utils.ts:255–277  ·  view source on GitHub ↗
(o: (new (config?: C) => T) | T, nestingLvl = 2, maxKeys = 3, maxLength = 5)

Source from the content-addressed store, hash-verified

253}
254
255export function randomValidValue<
256 T extends UnitBase<any> | Action<any>,
257 C extends BaseConfig | UnitConfig<any>
258>(o: (new (config?: C) => T) | T, nestingLvl = 2, maxKeys = 3, maxLength = 5) {
259 const isCtor = typeof o === 'function';
260 const ctorName = isCtor ? (o as new () => UnitBase<any>).name : o.constructor.name;
261
262 switch (ctorName) {
263 case 'BoolUnit':
264 return randomBoolean();
265 case 'NumUnit':
266 return randomWholeNumber();
267 case 'StringUnit':
268 return randomString();
269 case 'ListUnit':
270 return randomArray(maxLength);
271 case 'DictUnit':
272 return randomDictObject(nestingLvl, maxKeys);
273 case 'Action':
274 case 'GenericUnit':
275 return randomValue(nestingLvl);
276 }
277}
278
279export function unitsDefaultValue<T extends UnitBase<any>>(
280 unit: (new (config?: UnitConfig<any>) => T) | T

Callers 15

dispatchRandomValuesFunction · 0.90
units.spec.tsFile · 0.90
dict-unit.spec.tsFile · 0.90
cluster.spec.tsFile · 0.90
list-unit.spec.tsFile · 0.90
makeCaseFunction · 0.90
selection.spec.tsFile · 0.90
num-unit.spec.tsFile · 0.90

Calls 6

randomBooleanFunction · 0.85
randomWholeNumberFunction · 0.85
randomStringFunction · 0.85
randomArrayFunction · 0.85
randomDictObjectFunction · 0.85
randomValueFunction · 0.85

Tested by 2

dispatchRandomValuesFunction · 0.72
makeCaseFunction · 0.72