Subject

certainty~ Subject

new Subject(failureStrategy, value)

Represents the value being checked, and provides assertion methods. Can be subclassed to provide assertion methods that are type-specific.

Parameters:
Name Type Description
failureStrategy FailureStrategy

The failure strategy to use when an assertion fails.

value *

The value being checked.

Source:

Methods

describe()

Return a string description of the subject.

Source:

equals(expected) → {Subject}

Synonym for isEqualTo().

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

exists() → {Subject}

Synonym for isNotNullOrUndefined.

Source:
Returns:

this for chaining.

Type
Subject

(protected) fail(msg)

Generic failure method that takes a messasge.

Parameters:
Name Type Description
msg string

The failure message.

Source:

(protected) failComparison(verb, expected)

Failure method for simple comparison assertions.

Parameters:
Name Type Description
verb string

The name of the comparison verb, such has 'greater than'.

expected *

The value that we're comparing against.

Source:

(protected) failEqual(expected)

Failure method for simple comparison assertions.

Parameters:
Name Type Description
expected *

The expected value, which is different from the actual value.

Source:

(protected) failNotEqual(expected)

Failure method for simple negated comparison assertions.

Parameters:
Name Type Description
expected *

The expected value, which is the same as the actual value.

Source:

hasType(expected) → {Subject}

Ensure that the subject value has the expected type.

Parameters:
Name Type Description
expected string

The name of the expected type.

Source:
Returns:

this for chaining.

Type
Subject

isDeeplyEqualTo(expected) → {Subject}

Ensure that the subject value is equal to the expected value using a deep comparison.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isEqualTo(expected) → {Subject}

Ensure that the value is equal to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isExactly(expected) → {Subject}

Ensure that the subject value is exactly equal (===) to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isFalse() → {Subject}

Ensure that the subject value is false.

Source:
Returns:

this for chaining.

Type
Subject

isFalsey() → {Subject}

Ensure that the subject value is false when coerced to a boolean.

Source:
Returns:

this for chaining.

Type
Subject

isGreaterThan(expected) → {Subject}

Ensure that the subject value is greater than to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isIn(collection) → {Subject}

Ensure that the subject is in the specified collection.

Parameters:
Name Type Description
collection Collection

An array or set containing matchable elements.

Source:
Returns:

this for chaining.

Type
Subject

isInstanceOf(expected) → {Subject}

Ensure that the subject value is an instance of the expected type.

Parameters:
Name Type Description
expected Type

The expected type.

Source:
Returns:

this for chaining.

Type
Subject

isLessThan(expected) → {Subject}

Ensure that the subject value is less than to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isNotDeeplyEqualTo()

Ensure that the subject value is equal to the expected value using a deep comparison.

Source:

isNotEqualTo(expected) → {Subject}

Ensure that the subject value is not equal to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isNotGreaterThan(expected) → {Subject}

Ensure that the subject value is not greater than to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isNotInstanceOf(expected) → {Subject}

Ensure that the subject value is not an instance of the expected type.

Parameters:
Name Type Description
expected Type

The expected type.

Source:
Returns:

this for chaining.

Type
Subject

isNotLessThan(expected) → {Subject}

Ensure that the subject value is not less than to the expected value.

Parameters:
Name Type Description
expected *

The expected value.

Source:
Returns:

this for chaining.

Type
Subject

isNotNull() → {Subject}

Ensure that the subject value is not null.

Source:
Returns:

this for chaining.

Type
Subject

isNotNullOrUndefined() → {Subject}

Ensure that the subject value is not null or undefined.

Source:
Returns:

this for chaining.

Type
Subject

isNotUndefined() → {Subject}

Ensure that the subject value is not undefined.

Source:
Returns:

this for chaining.

Type
Subject

isNull() → {Subject}

Ensure that the subject value is null.

Source:
Returns:

this for chaining.

Type
Subject

isNullOrUndefined() → {Subject}

Ensure that the subject value is null or undefined.

Source:
Returns:

this for chaining.

Type
Subject

isTrue() → {Subject}

Ensure that the subject value is true.

Source:
Returns:

this for chaining.

Type
Subject

isTruthy() → {Subject}

Ensure that the subject value is true when coerced to a boolean.

Source:
Returns:

this for chaining.

Type
Subject

isUndefined() → {Subject}

Ensure that the subject value is undefined.

Source:
Returns:

this for chaining.

Type
Subject

named(name) → {Subject}

Assign a descriptive name to the subject.

Parameters:
Name Type Description
name string

The name to assign to this subject.

Source:
Returns:

this for chaining.

Type
Subject

withFailureMessage(msg) → {Subject}

Override the normal failure message.

Parameters:
Name Type Description
msg string

The failure message to use on failure.

Source:
Returns:

this for chaining.

Type
Subject