Utility module that generates random values to be used during testing.
Where possible, generated values are suffixed with a property name to allow
for easy debugging.
- Source:
Methods
(static) allButArray(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
an array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButBoolean(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
a boolean.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButFunction(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
a function.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButNull(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
a null value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButNumber(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
a number.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButObject(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
an object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButSelected(…omitopt) → {Array}
- Source:
Returns an array of test values, omitting the requested arg types. The
requested arg types must be the type of the arg to be omitted. For
example, string arguments can be omitted by specifying 'string', null
values by specifying 'null' and so on.
The exception to this rule is for Arrays. Arrays have a type of 'object', but the method will honor the literal string 'array' and strip out array objects when this value is provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
omit |
* |
<optional> <repeatable> |
Args to be omitted from the test values. |
Returns:
An array of test values
- Type
- Array
(static) allButString(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
a string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) allButUndefined(…extrasopt) → {Array}
- Source:
Returns an array of values that has valid samples of all types except
an undefined value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
extras |
* |
<optional> <repeatable> |
Optional extra parameters to append to the test value list. |
Returns:
An array of test values
- Type
- Array
(static) getNumber(rangeopt, startopt) → {Number}
- Source:
Generates and returns a random integer by using the start value, shifted
up or down by a random value within the specified range.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
range |
Number |
<optional> |
100
|
The range from which to choose the number. Positive value shift up, negative values shift down. |
start |
Number |
<optional> |
0
|
An optional start point, defaults to 0. |
Returns:
A random number generated within the range.
- Type
- Number
(static) getString(prefixopt) → {String}
- Source:
Generates and returns a new random string, prefixed with the specified
value.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefix |
String |
<optional> |
''
|
A constant prefix for the generated value. Useful when debugging tests. |
Returns:
The generated string.
- Type
- String
(static) getTimestamp(rangeopt, startopt) → {Number}
- Source:
Generates and returns a timestamp value based on the current timestamp,
shifted up or down by a random value within the specified range.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
range |
Number |
<optional> |
10000
|
The range (in milliseconds) to use when generating random shifts. Positive values shift up, negative values shift down. |
start |
Number |
<optional> |
<current time>
|
An optional start timestamp, defaults to the current time. |
Returns:
A timestamp value used for testing.
- Type
- Number