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

    Interface IHasOp<R>

    Provides the 'has' operation for the assert scope.

    interface IHasOp<R> {
        all: IAllOp<R>;
        any: IAnyOp<R>;
        iterator: SymbolFn;
        lengthOf(n: number, evalMsg?: MsgSource): R;
        nested: INestedOp<R>;
        own: IOwnOp<R>;
        property: PropertyFn;
        propertyDescriptor: PropertyDescriptorFn;
        sizeOf(n: number, evalMsg?: MsgSource): R;
    }

    Type Parameters

    • R
    Index

    Properties

    all: IAllOp<R>

    Provides the all assertion operations.

    expect({ a: 1, b: 2 }).has.all.keys('a', 'b');
    
    any: IAnyOp<R>

    Provides the any assertion operations.

    expect({ a: 1, b: 2 }).has.any.keys('a', 'b');
    
    iterator: SymbolFn

    Asserts that the object has the Symbol.iterator property.

    expect({ [Symbol.iterator]: () => {} }).has.iterator();
    
    nested: INestedOp<R>

    Provides nested property operations using dot notation.

    expect({ a: { b: { c: 1 } } }).has.nested.property('a.b.c');
    expect({ a: { b: { c: 1 } } }).to.have.nested.property('a.b.c', 1);
    own: IOwnOp<R>

    Asserts that the object has the specified own property.

    expect({ a: 1, b: 2 }).has.own.property('a');
    
    property: PropertyFn

    Asserts that the object has the specified property.

    expect({ a: 1, b: 2 }).has.property('a');
    
    propertyDescriptor: PropertyDescriptorFn

    Asserts that the object has the specified property descriptor.

    expect({ a: 1, b: 2 }).has.propertyDescriptor('a');
    

    Methods

    • Asserts that the target has a length or size property equal to the given number. Works with arrays, strings, Maps, Sets, and any object with a length or size property.

      Parameters

      • n: number
      • OptionalevalMsg: MsgSource

        Optional error message.

      Returns R

      0.1.5

      expect([1, 2, 3]).has.lengthOf(3);           // Passes - array length is 3
      expect("hello").has.lengthOf(5); // Passes - string length is 5
      expect(new Map([["a", 1]])).has.lengthOf(1); // Passes - Map size is 1
      expect(new Set([1, 2])).has.lengthOf(2); // Passes - Set size is 2
    • Asserts that the target has a size or length property equal to the given number. Works with arrays, strings, Maps, Sets, and any object with a length or size property.

      Parameters

      • n: number
      • OptionalevalMsg: MsgSource

        Optional error message.

      Returns R

      0.1.5

      expect([1, 2, 3]).has.sizeOf(3);           // Passes - array length is 3
      expect("hello").has.sizeOf(5); // Passes - string length is 5
      expect(new Map([["a", 1]])).has.sizeOf(1); // Passes - Map size is 1
      expect(new Set([1, 2])).has.sizeOf(2); // Passes - Set size is 2