Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMocked<T, C>

Type parameters

Hierarchy

  • IMocked

Index

Properties

functionCallLookup

functionCallLookup: FunctionCallLookup<T, C, "function">

functionReplacementLookup

functionReplacementLookup: Partial<Record<LookupType, Record<string, ((...args: any[]) => any) | undefined>>>

getterCallLookup

getterCallLookup: FunctionCallLookup<T, C, "getter">

mock

mock: T

The mocked object. This should be passed to your SUT.

mockConstructor

mockConstructor: C

The mocked constructor (if statics have been mocked). This can be used to return the mocked instance with new myMock.constructor() and for accessing statics.

setterCallLookup

setterCallLookup: FunctionCallLookup<T, C, "setter">

staticFunctionCallLookup

staticFunctionCallLookup: FunctionCallLookup<T, C, "staticFunction">

staticGetterCallLookup

staticGetterCallLookup: FunctionCallLookup<T, C, "staticGetter">

staticSetterCallLookup

staticSetterCallLookup: FunctionCallLookup<T, C, "staticSetter">

Methods

defineProperty

  • defineProperty<K>(propertyname: K, getter?: undefined | (() => T[K]), setter?: undefined | ((value: T[K]) => void)): IFunctionVerifier<T, "getter", C>
  • Defines a single property and allows getters and setters to be defined. Returns a function verifier to verify get and set operations

    Type parameters

    • K: keyof T

    Parameters

    • propertyname: K
    • Optional getter: undefined | (() => T[K])
    • Optional setter: undefined | ((value: T[K]) => void)

    Returns IFunctionVerifier<T, "getter", C>

defineStaticProperty

  • defineStaticProperty<K>(propertyname: K, getter?: undefined | (() => C[K]), setter?: undefined | ((value: C[K]) => void)): IFunctionVerifier<T, "staticGetter", C>
  • Defines a single static property and allows getters and setters to be defined. Returns a function verifier to verify get and set operations

    Type parameters

    • K: keyof C

    Parameters

    • propertyname: K
    • Optional getter: undefined | (() => C[K])
    • Optional setter: undefined | ((value: C[K]) => void)

    Returns IFunctionVerifier<T, "staticGetter", C>

setup

  • Used to setup the mock with multiple operators.

    Mock.create().setup( setupFunction("functionName"), setupFunction("otherFunction"), setupProperty("propertyName"), );

    Parameters

    Returns IMocked<T, C>

setupFunction

setupProperty

  • Sets up a single property and returns a function verifier to verify value get or set operations.

    Type parameters

    • K: keyof T

    Parameters

    • propertyname: K
    • Optional value: T[K]

    Returns IFunctionVerifier<T, "getter", C>

setupStaticFunction

setupStaticProperty

  • setupStaticProperty<K>(propertyname: K, value?: C[K]): IFunctionVerifier<T, "staticGetter", C>
  • Sets up a single static property and returns a function verifier to verify value get or set operations.

    Type parameters

    • K: keyof C

    Parameters

    • propertyname: K
    • Optional value: C[K]

    Returns IFunctionVerifier<T, "staticGetter", C>

withFunction

  • Verifies calls to a previously setup function. expect(myMock.withFunction("functionName")).wasNotCalled(): expect(myMock.withFunction("functionName")).wasCalledOnce(): expect(myMock.withFunction("functionName").withParameters("one", 2)).wasCalledOnce():

    Type parameters

    Parameters

    • functionName: K

    Returns IFunctionWithParametersVerification<FunctionParams<T[K]>, T, "function", C>

withGetter

  • Verifies calls to a previously setup getter. expect(myMock.withGetter("propertyName")).wasNotCalled(): expect(myMock.withGetter("propertyName")).wasCalledOnce():

    Type parameters

    • K: keyof T

    Parameters

    • propertyname: K

    Returns IFunctionVerifier<T, "getter", C>

withSetter

  • Verifies calls to a previously setup setter. expect(myMock.withSetter("propertyName")).wasNotCalled(): expect(myMock.withSetter("propertyName")).wasCalledOnce(): expect(myMock.withSetter("propertyName").withParameters("one")).wasCalledOnce():

    Type parameters

    • K: keyof T

    Parameters

    • propertyname: K

    Returns IFunctionWithParametersVerification<[], T, "setter", C>

withStaticFunction

  • Verifies calls to a previously setup static function. expect(myMock.withStaticFunction("functionName")).wasNotCalled(): expect(myMock.withStaticFunction("functionName")).wasCalledOnce(): expect(myMock.withStaticFunction("functionName").withParameters("one", 2)).wasCalledOnce():

    Type parameters

    Parameters

    • functionName: K

    Returns IFunctionWithParametersVerification<FunctionParams<C[K]>, T, "staticFunction", C>

withStaticGetter

  • Verifies calls to a previously setup static getter. expect(myMock.withStaticGetter("functionName")).wasNotCalled(): expect(myMock.withStaticGetter("functionName")).wasCalledOnce():

    Type parameters

    • K: keyof C

    Parameters

    • propertyname: K

    Returns IFunctionVerifier<T, "staticGetter", C>

withStaticSetter

  • Verifies calls to a previously setup static setter. expect(myMock.withStaticSetter("functionName")).wasNotCalled(): expect(myMock.withStaticSetter("functionName")).wasCalledOnce(): expect(myMock.withStaticSetter("functionName").withParameters("one")).wasCalledOnce():

    Type parameters

    • K: keyof C

    Parameters

    • propertyname: K

    Returns IFunctionWithParametersVerification<[], T, "staticSetter", C>

Generated using TypeDoc