@nevware21/tripwire - v0.1.2
    Preparing search index...

    Interface IToOp<R>

    Represents an interface for operations that can be performed on an assertion scope. This represents a logical grouping of assertion operations, which is used to provide a descriptive API for assertion operations.

    interface IToOp<R> {
        be: IIsOp<R>;
        contain: IIncludeOp<IToOp<R>>;
        contains: IIncludeOp<IToOp<R>>;
        deep: IDeepOp<IToOp<R>>;
        have: IHasOp<R>;
        include: IIncludeOp<IToOp<R>>;
        includes: IIncludeOp<IToOp<R>>;
        match(regexp: RegExp, evalMsg?: MsgSource): R;
        not: IToOp;
        strictly: IStrictlyOp<IToOp<R>>;
        throw: ThrowFn;
    }

    Type Parameters

    • R

      The type of the result of the operation.

    Hierarchy (View Summary)

    Index

    Properties

    be: IIsOp<R>

    Provides access to operations that can be performed on the assertion scope, based on the IIsOp interface.

    The operations that can be performed on the assertion scope.

    contain: IIncludeOp<IToOp<R>>

    Provides operations for containment checks.

    This operation allows you to assert that the target value contains the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.

    include

    import { assert } from "@nevware21/tripwire";

    const arr = [1, 2, 3];
    const str = "hello darkness my old friend";
    const obj = { a: 1, b: 2, c: 3 };

    assert(arr).contain(2); // Passes
    assert(str).contain("darkness"); // Passes
    assert(obj).contain.all.keys('a', 'b'); // Passes
    assert(arr).contain(4); // Fails
    assert(str).contain("planet"); // Fails
    assert(obj).contain.all.keys('a', 'd'); // Fails
    contains: IIncludeOp<IToOp<R>>

    Provides operations for containment checks.

    This operation allows you to assert that the target value contains the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.

    include

    import { assert } from "@nevware21/tripwire";

    const arr = [1, 2, 3];
    const str = "hello darkness my old friend";
    const obj = { a: 1, b: 2, c: 3 };

    assert(arr).contains(2); // Passes
    assert(str).contains("darkness"); // Passes
    assert(obj).contains.all.keys('a', 'b'); // Passes
    assert(arr).contains(4); // Fails
    assert(str).contains("planet"); // Fails
    assert(obj).contains.all.keys('a', 'd'); // Fails
    deep: IDeepOp<IToOp<R>>

    This operation provides access to operations that will deeplyallows you to assert that the target value deeply equals the expected value. It is useful for comparing objects, arrays, and other complex structures.

    import { assert } from "@nevware21/tripwire";

    assert({ a: 1, b: { c: 2 } }).deep.equal({ a: 1, b: { c: 2 } }); // Passes
    assert([1, [2, 3]]).deep.equal([1, [2, 3]]); // Passes
    assert({ a: 1, b: { c: 2 } }).deep.equal({ a: 1, b: { c: 3 } }); // Fails
    have: IHasOp<R>

    Provides access to operations that can be performed on the assertion scope, based on the IHasOp interface.

    The operations that can be performed on the assertion scope.

    include: IIncludeOp<IToOp<R>>

    Provides operations for inclusion checks.

    This operation allows you to assert that the target value includes the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.

    import { assert } from "@nevware21/tripwire";

    const arr = [1, 2, 3];
    const str = "hello darkness my old friend";
    const obj = { a: 1, b: 2, c: 3 };

    assert(arr).include(2); // Passes
    assert(str).include("darkness"); // Passes
    assert(obj).include.all.keys('a', 'b'); // Passes
    assert(arr).include(4); // Fails
    assert(str).include("planet"); // Fails
    assert(obj).include.all.keys('a', 'd'); // Fails
    includes: IIncludeOp<IToOp<R>>

    Provides operations for inclusion checks.

    This operation allows you to assert that the target value includes the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.

    include

    import { assert } from "@nevware21/tripwire";

    const arr = [1, 2, 3];
    const str = "hello darkness my old friend";
    const obj = { a: 1, b: 2, c: 3 };

    assert(arr).includes(2); // Passes
    assert(str).includes("darkness"); // Passes
    assert(obj).includes.all.keys('a', 'b'); // Passes
    assert(arr).includes(4); // Fails
    assert(str).includes("planet"); // Fails
    assert(obj).includes.all.keys('a', 'd'); // Fails
    not: IToOp

    Negates any performed evaluations that are performed in the assertion chain.

    This operation applies a stateful change to the evaluation chain, meaning that subsequent operations that would normally fail will pass without the need for them to "implement" any knowledge about the not operation. You may call not multiple times to negate the negation.

    import { assert } from "@nevware21/tripwire";

    expect(true).not.ok(); // Fails
    expect(false).not.ok(); // Passes
    expect(true).not.not.ok(); // Passes
    expect(false).not.not.ok(); // Fails
    strictly: IStrictlyOp<IToOp<R>>

    Provides operations for strict equality checks.

    This operation allows you to assert that the target value is strictly equal to the expected value. It is useful for comparing values without any type coercion.

    import { assert } from "@nevware21/tripwire";

    assert(1).strictly.equal(1); // Passes
    assert(1).strictly.equal("1"); // Fails
    throw: ThrowFn

    An assertion function that will validate that the actual value is a function that when executed will throw an error.

    Optional. The message to display if the assertion fails.

    The result of the operation.

    AssertionFailure - If the function does not throw an error.

    Methods