Assert
Static Method Summary
Static Public Methods | ||
public static |
Asserts that value is valid array. |
|
public static |
Asserts that value is valid boolean |
|
public static |
containsOnly(arrayValue: array, expectedInstance: function, message: string) Asserts that array contains only instances of specific class. |
|
public static |
containsOnlyInteger(arrayValue: array, message: string) Asserts that array contains only integers |
|
public static |
containsOnlyNumber(arrayValue: array, message: string) Asserts that array contains only numbers |
|
public static |
containsOnlyString(arrayValue: array, message: string) Asserts that array contains only strings |
|
public static |
Asserts that array have specific number of elements |
|
public static |
Asserts that object is equal to expected object |
|
public static |
Asserts that string is valid email address. |
|
public static |
Asserts that value is equal to expected value |
|
public static |
evenNumber(integerValue: int, message: string) Asserts that value is even number |
|
public static |
Asserts that expression or value is equal to false. |
|
public static |
greaterThan(expected: int, integerValue: int, message: string) Asserts that number is greater than |
|
public static |
greaterThanOrEqual(expected: int, integerValue: int, message: string) Asserts that number is greater than or equal |
|
public static |
hasAttribute(attributeName: string, htmlElement: HTMLElement, message: string) Asserts that element has expected attribute (it might be empty) |
|
public static |
hasAttributes(attributes: array, htmlElement: HTMLElement, message: string) Asserts that element has expected attributes (it might be empty) |
|
public static |
hasElement(selector: string, htmlElement: HTMLElement | HTMLDocument, message: string) Asserts that element has other element under selector. |
|
public static |
hasFunction(expectedFunctionName: string, objectValue: object, message: string) Asserts that object has function |
|
public static |
hasProperties(expectedProperties: array, objectValue: object, message: string) Asserts that object has multiple properties |
|
public static |
hasProperty(expectedPropertyName: string, objectValue: object, message: string) Asserts that object has property (it can also be a function) |
|
public static |
instanceOf(objectValue: object, expectedInstance: function, message: string) Asserts that value is an instance of (at least one) specific class. |
|
public static |
instanceOneOf(objectValue: object, expectedInstances: array, message: string) Asserts that value is an instance of at least one specific class. |
|
public static |
Asserts that value is valid integer |
|
public static |
isFunction(functionValue: function, message: string) Asserts that value is valid function |
|
public static |
jsonString(stringValue: string, message: string) Asserts that value is valid json string |
|
public static |
Asserts that number is less than |
|
public static |
lessThanOrEqual(expected: int, integerValue: int, message: string) Asserts that number is less than or equal |
|
public static |
Asserts that array is not empty |
|
public static |
Asserts that value is valid number (integer, float) |
|
public static |
Asserts that value is valid object |
|
public static |
objectEqual(value: object, otherValue: object, message: string): * Asserts that object is equal to expected object |
|
public static |
Asserts that value is odd number |
|
public static |
Asserts that a value is truthy |
|
public static |
Asserts that value is one of expected values |
|
public static |
strictEqual(value: *, otherValue: *, message: string) |
|
public static |
Assert that value is valid string |
|
public static |
Asserts that expression or value is exactly equal to true. |
|
public static |
Asserts that string is valid url |
|
public static |
Asserts that string is valid UUID |
Static Public Methods
public static array(arrayValue: array, message: string) source
Asserts that value is valid array.
Example:
Assert.array([1, 2]);
public static boolean(booleanValue: boolean, message: string) source
Asserts that value is valid boolean
Example:
Assert.boolean(true);
public static containsOnly(arrayValue: array, expectedInstance: function, message: string) source
Asserts that array contains only instances of specific class.
Example:
Assert.containsOnly([new Foo, new Foo], Foo)
public static containsOnlyInteger(arrayValue: array, message: string) source
Asserts that array contains only integers
Example:
Assert.containsOnlyInteger([1, 2])
public static containsOnlyNumber(arrayValue: array, message: string) source
Asserts that array contains only numbers
Example:
Assert.containsOnlyNumber([1, 2])
public static containsOnlyString(arrayValue: array, message: string) source
Asserts that array contains only strings
Example:
Assert.containsOnlyString(['Foo', 'Bar'])
public static count(expectedCount: int, arrayValue: array, message: string) source
Asserts that array have specific number of elements
Example:
Assert.expectedCount(2, [1, 2])
public static deepEqual(value: *, otherValue: *, message: string) source
Asserts that object is equal to expected object
Params:
Name | Type | Attribute | Description |
value | * | Value to check |
|
otherValue | * | Value to compare |
|
message | string |
|
Error message for the for the user |
Example:
Assert.deepEqua({foo: 1}, {foo: 1});
public static email(emailValue: string, message: string) source
Asserts that string is valid email address.
Example:
Assert.email("sebs@2xs.org")
public static equal(value: *, expectedValue: *, message: string) source
Asserts that value is equal to expected value
Params:
Name | Type | Attribute | Description |
value | * | Value to check |
|
expectedValue | * | Value to compare |
|
message | string |
|
Error message for the for the user |
Example:
Assert.equal(1, 1)
public static evenNumber(integerValue: int, message: string) source
Asserts that value is even number
Params:
Name | Type | Attribute | Description |
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.evenNumber(2)
public static false(value: boolean, message: string) source
Asserts that expression or value is equal to false.
Example:
Assert.false(false)
public static greaterThan(expected: int, integerValue: int, message: string) source
Asserts that number is greater than
Params:
Name | Type | Attribute | Description |
expected | int | ||
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.greaterThan(12, 13)
public static greaterThanOrEqual(expected: int, integerValue: int, message: string) source
Asserts that number is greater than or equal
Params:
Name | Type | Attribute | Description |
expected | int | ||
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.greaterThanOrEqual(12, 12)
public static hasAttribute(attributeName: string, htmlElement: HTMLElement, message: string) source
Asserts that element has expected attribute (it might be empty)
public static hasAttributes(attributes: array, htmlElement: HTMLElement, message: string) source
Asserts that element has expected attributes (it might be empty)
public static hasElement(selector: string, htmlElement: HTMLElement | HTMLDocument, message: string) source
Asserts that element has other element under selector.
public static hasFunction(expectedFunctionName: string, objectValue: object, message: string) source
Asserts that object has function
Example:
Assert.hasFunction('postMessage', window)
public static hasProperties(expectedProperties: array, objectValue: object, message: string) source
Asserts that object has multiple properties
Example:
Assert.hasProperty(['postMessage', 'location'], window)
public static hasProperty(expectedPropertyName: string, objectValue: object, message: string) source
Asserts that object has property (it can also be a function)
Example:
Assert.hasProperty('postMessage', window)
public static instanceOf(objectValue: object, expectedInstance: function, message: string) source
Asserts that value is an instance of (at least one) specific class.
Example:
class X {}; Asssert.instanceOf(new X, X);
public static instanceOneOf(objectValue: object, expectedInstances: array, message: string) source
Asserts that value is an instance of at least one specific class.
public static integer(integerValue: int, message: string) source
Asserts that value is valid integer
Params:
Name | Type | Attribute | Description |
integerValue | int | Integer value to check |
|
message | string |
|
Error message for the for the user |
Example:
Assert.integer(1)
public static isFunction(functionValue: function, message: string) source
Asserts that value is valid function
Params:
Name | Type | Attribute | Description |
functionValue | function | ||
message | string |
|
Error message for the for the user |
Example:
Assert.isFunction(window.postMessage)
public static jsonString(stringValue: string, message: string) source
Asserts that value is valid json string
Example:
Assert.jsonString("[]")
public static lessThan(expected: int, integerValue: int, message: string) source
Asserts that number is less than
Params:
Name | Type | Attribute | Description |
expected | int | ||
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.lessThan(10, 12)
public static lessThanOrEqual(expected: int, integerValue: int, message: string) source
Asserts that number is less than or equal
Params:
Name | Type | Attribute | Description |
expected | int | ||
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.lessThanOrEqual(10, 10);
public static notEmpty(value: *, message: string) source
Asserts that array is not empty
Params:
Name | Type | Attribute | Description |
value | * | ||
message | string |
|
Error message for the for the user |
Example:
Assert.notEmpty([1])
public static number(numberValue: number, message: string) source
Asserts that value is valid number (integer, float)
Example:
Assert.number(1.5)
public static object(objectValue: object, message: string) source
Asserts that value is valid object
Example:
Assert.object(document)
public static objectEqual(value: object, otherValue: object, message: string): * source
Asserts that object is equal to expected object
Return:
* |
Example:
Assert.objectEqual({foo: 1}, {foo: 1});
public static oddNumber(integerValue: int, message: string) source
Asserts that value is odd number
Params:
Name | Type | Attribute | Description |
integerValue | int | ||
message | string |
|
Error message for the for the user |
Example:
Assert.oddNumber(1)
public static ok(value: boolean, message: string) source
Asserts that a value is truthy
Example:
Assert.ok('Anytzhing but null false or undefined')
public static oneOf(value: *, expectedElements: array, message: string) source
Asserts that value is one of expected values
Example:
Assert.oneOf([1, 2]);
public static strictEqual(value: *, otherValue: *, message: string) source
Params:
Name | Type | Attribute | Description |
value | * | Value to check |
|
otherValue | * | Value to compare |
|
message | string |
|
Error message for the for the user |
Example:
Assert.strictEqual(1, 1);
public static true(value: boolean, message: string) source
Asserts that expression or value is exactly equal to true.
Example:
Assert.true(true);