Home Reference Source
public class | source

Assert

Static Method Summary

Static Public Methods
public static

array(arrayValue: array, message: string)

Asserts that value is valid array.

public static

boolean(booleanValue: boolean, message: string)

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

count(expectedCount: int, arrayValue: array, message: string)

Asserts that array have specific number of elements

public static

deepEqual(value: *, otherValue: *, message: string)

Asserts that object is equal to expected object

public static

email(emailValue: string, message: string)

Asserts that string is valid email address.

public static

equal(value: *, expectedValue: *, message: string)

Asserts that value is equal to expected value

public static

evenNumber(integerValue: int, message: string)

Asserts that value is even number

public static

false(value: boolean, message: string)

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

integer(integerValue: int, message: string)

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

lessThan(expected: int, integerValue: int, message: string)

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

notEmpty(value: *, message: string)

Asserts that array is not empty

public static

number(numberValue: number, message: string)

Asserts that value is valid number (integer, float)

public static

object(objectValue: object, message: string)

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

oddNumber(integerValue: int, message: string)

Asserts that value is odd number

public static

ok(value: boolean, message: string)

Asserts that a value is truthy

public static

oneOf(value: *, expectedElements: array, message: string)

Asserts that value is one of expected values

public static

strictEqual(value: *, otherValue: *, message: string)

public static

string(stringValue: string, message: string)

Assert that value is valid string

public static

true(value: boolean, message: string)

Asserts that expression or value is exactly equal to true.

public static

url(urlValue: string, message: string)

Asserts that string is valid url

public static

uuid(uuidValue: string, message: string)

Asserts that string is valid UUID

Static Public Methods

public static array(arrayValue: array, message: string) source

Asserts that value is valid array.

Params:

NameTypeAttributeDescription
arrayValue array
message string
  • optional

Error message for the for the user

Example:

Assert.array([1, 2]);

public static boolean(booleanValue: boolean, message: string) source

Asserts that value is valid boolean

Params:

NameTypeAttributeDescription
booleanValue boolean

Boolean value to check

message string
  • optional

Error message for the for the user

Example:

Assert.boolean(true);

public static containsOnly(arrayValue: array, expectedInstance: function, message: string) source

Asserts that array contains only instances of specific class.

Params:

NameTypeAttributeDescription
arrayValue array
expectedInstance function
message string
  • optional

Error message for the for the user

Example:

Assert.containsOnly([new Foo, new Foo], Foo)

public static containsOnlyInteger(arrayValue: array, message: string) source

Asserts that array contains only integers

Params:

NameTypeAttributeDescription
arrayValue array
message string
  • optional

Error message for the for the user

Example:

Assert.containsOnlyInteger([1, 2])

public static containsOnlyNumber(arrayValue: array, message: string) source

Asserts that array contains only numbers

Params:

NameTypeAttributeDescription
arrayValue array
message string
  • optional

Error message for the for the user

Example:

Assert.containsOnlyNumber([1, 2])

public static containsOnlyString(arrayValue: array, message: string) source

Asserts that array contains only strings

Params:

NameTypeAttributeDescription
arrayValue array
message string
  • optional

Error message for the for the user

Example:

Assert.containsOnlyString(['Foo', 'Bar'])

public static count(expectedCount: int, arrayValue: array, message: string) source

Asserts that array have specific number of elements

Params:

NameTypeAttributeDescription
expectedCount int
arrayValue array
message string
  • optional

Error message for the for the user

Example:

Assert.expectedCount(2, [1, 2])

public static deepEqual(value: *, otherValue: *, message: string) source

Asserts that object is equal to expected object

Params:

NameTypeAttributeDescription
value *

Value to check

otherValue *

Value to compare

message string
  • optional

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.

Params:

NameTypeAttributeDescription
emailValue string
message string
  • optional

Error message for the for the user

Example:

Assert.email("sebs@2xs.org")

public static equal(value: *, expectedValue: *, message: string) source

Asserts that value is equal to expected value

Params:

NameTypeAttributeDescription
value *

Value to check

expectedValue *

Value to compare

message string
  • optional

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:

NameTypeAttributeDescription
integerValue int
message string
  • optional

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.

Params:

NameTypeAttributeDescription
value boolean

Value to check

message string
  • optional

Error message for the for the user

Example:

Assert.false(false)

public static greaterThan(expected: int, integerValue: int, message: string) source

Asserts that number is greater than

Params:

NameTypeAttributeDescription
expected int
integerValue int
message string
  • optional

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:

NameTypeAttributeDescription
expected int
integerValue int
message string
  • optional

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)

Params:

NameTypeAttributeDescription
attributeName string
htmlElement HTMLElement
message string
  • optional

Error message for the for the user

public static hasAttributes(attributes: array, htmlElement: HTMLElement, message: string) source

Asserts that element has expected attributes (it might be empty)

Params:

NameTypeAttributeDescription
attributes array
htmlElement HTMLElement
message string
  • optional

Error message for the for the user

public static hasElement(selector: string, htmlElement: HTMLElement | HTMLDocument, message: string) source

Asserts that element has other element under selector.

Params:

NameTypeAttributeDescription
selector string
htmlElement HTMLElement | HTMLDocument
message string
  • optional

Error message for the for the user

public static hasFunction(expectedFunctionName: string, objectValue: object, message: string) source

Asserts that object has function

Params:

NameTypeAttributeDescription
expectedFunctionName string
objectValue object
message string
  • optional

Error message for the for the user

Example:

Assert.hasFunction('postMessage', window)

public static hasProperties(expectedProperties: array, objectValue: object, message: string) source

Asserts that object has multiple properties

Params:

NameTypeAttributeDescription
expectedProperties array
objectValue object
message string
  • optional

Error message for the for the user

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)

Params:

NameTypeAttributeDescription
expectedPropertyName string
objectValue object
message string
  • optional

Error message for the for the user

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.

Params:

NameTypeAttributeDescription
objectValue object

value to compare

expectedInstance function

expected class Instance

message string
  • optional

Error message for the for the user

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.

Params:

NameTypeAttributeDescription
objectValue object

value to compare

expectedInstances array

instances to compare the value with

message string
  • optional

Error message for the for the user

public static integer(integerValue: int, message: string) source

Asserts that value is valid integer

Params:

NameTypeAttributeDescription
integerValue int

Integer value to check

message string
  • optional

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:

NameTypeAttributeDescription
functionValue function
message string
  • optional

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

Params:

NameTypeAttributeDescription
stringValue string
message string
  • optional

Error message for the for the user

Example:

Assert.jsonString("[]")

public static lessThan(expected: int, integerValue: int, message: string) source

Asserts that number is less than

Params:

NameTypeAttributeDescription
expected int
integerValue int
message string
  • optional

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:

NameTypeAttributeDescription
expected int
integerValue int
message string
  • optional

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:

NameTypeAttributeDescription
value *
message string
  • optional

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)

Params:

NameTypeAttributeDescription
numberValue number

Numeric value to check

message string
  • optional

Error message for the for the user

Example:

Assert.number(1.5)

public static object(objectValue: object, message: string) source

Asserts that value is valid object

Params:

NameTypeAttributeDescription
objectValue object
message string
  • optional

Error message for the for the user

Example:

Assert.object(document)

public static objectEqual(value: object, otherValue: object, message: string): * source

Asserts that object is equal to expected object

Params:

NameTypeAttributeDescription
value object

Value to check

otherValue object

Value to compare

message string
  • optional

Error message for the for the user

Return:

*

Example:

Assert.objectEqual({foo: 1}, {foo: 1});

public static oddNumber(integerValue: int, message: string) source

Asserts that value is odd number

Params:

NameTypeAttributeDescription
integerValue int
message string
  • optional

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

Params:

NameTypeAttributeDescription
value boolean

Truthy value to check

message string
  • optional

Error message for the for the user

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

Params:

NameTypeAttributeDescription
value *
expectedElements array
message string
  • optional

Error message for the for the user

Example:

Assert.oneOf([1, 2]);

public static strictEqual(value: *, otherValue: *, message: string) source

Params:

NameTypeAttributeDescription
value *

Value to check

otherValue *

Value to compare

message string
  • optional

Error message for the for the user

Example:

Assert.strictEqual(1, 1);

public static string(stringValue: string, message: string) source

Assert that value is valid string

Params:

NameTypeAttributeDescription
stringValue string

String value to check

message string
  • optional

Error message for the for the user @example: Assert.string('foo')

public static true(value: boolean, message: string) source

Asserts that expression or value is exactly equal to true.

Params:

NameTypeAttributeDescription
value boolean

Value to check

message string
  • optional

Error message for the for the user

Example:

 Assert.true(true);

public static url(urlValue: string, message: string) source

Asserts that string is valid url

Params:

NameTypeAttributeDescription
urlValue string
message string
  • optional

Error message for the for the user

Example:

Assert.url("http://google.de")

public static uuid(uuidValue: string, message: string) source

Asserts that string is valid UUID

Params:

NameTypeAttributeDescription
uuidValue string
message string
  • optional

Error message for the for the user

Example:

Assert.uuid("550e8400-e29b-11d4-a716-446655440000")