addSpecialType (Type, valueCallback, captionCallback)
Adds new special type definition. Methods isLike() and notLike() compares own properties of tested objects.
Special types allows to define own values to be used in testing.
Parameters:
Name |
Type |
Description |
Type |
function
|
Object's constructor. |
valueCallback |
function
|
function(val){ return val.something; } returns a value for testing.
|
captionCallback |
function
|
function(val){ return val.toString(); } returns a string to show in report dialog.
|
Example:
// Before using a special type definition:
// test passed because Date doesn't have own properties,
// but dates are different
it.isLike('', new Date(), new Date(1000));
// Let's define Date as a special type:
it.addSpecialType(
Date,
function(val) { return val.getTime(); },
function(val) { return 'Date("' + val.toLocaleString() + '")'; }
);
it.notLike('', new Date(), new Date(1000));
it.isLike('', new Date(1000), new Date(1000));
// and that we wished
|
addSpecialTypeDef (def)
Adds new special type definition.
Parameters:
Name |
Type |
Description |
def |
Object
|
{constr: Type, value: Function, caption: Function}
|
Throws:
|
is (name, actual, expected)
Tests if values are identical.
Parameters:
Name |
Type |
Description |
name |
string
|
|
actual |
*
|
|
expected |
*
|
|
|
isLike (name, actual, expected, depthopt)
Tests if values are equal.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
|
|
|
actual |
*
|
|
|
|
expected |
*
|
|
|
|
depth |
int
|
<optional>
|
10
|
Nesting level of the comparison of the objects. |
|
isMember (name, actual, expected)
Tests if actual value is member of the expected value.
Parameters:
Name |
Type |
Description |
name |
string
|
|
actual |
*
|
|
expected |
*
|
|
|
isNot (name, actual, expected)
Tests if values are not identical.
Parameters:
Name |
Type |
Description |
name |
string
|
|
actual |
*
|
|
expected |
*
|
|
|
isThrown (name, actual, expectedopt)
Tests if actual function throws exception.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
|
actual |
function
|
|
|
expected |
*
|
<optional>
|
|
|
notLike (name, actual, expected, depthopt)
Tests if values are not equal.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
|
|
|
actual |
*
|
|
|
|
expected |
*
|
|
|
|
depth |
int
|
<optional>
|
10
|
Nesting level of the comparison of the objects. |
|
notMember (name, actual, expected)
Tests if actual value is not member of the expected value.
Parameters:
Name |
Type |
Description |
name |
string
|
|
actual |
*
|
|
expected |
*
|
|
|
notThrown (name, actual, expectedopt)
Tests if actual function doesn't throw exception.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
|
actual |
function
|
|
|
expected |
*
|
<optional>
|
|
|
toString () → {string}
Returns a string representation of the object.
Returns:
|