API Docs for: 0.1.0

Class gabarito.Spy

Class defined in: lib/gabarito.js:1296

The spy relays the calls to the actual function, but records every call, along with its parameters, its return or error if thrown.

To verify a given call, the gabarito.SpyVerifier may be obtained through the verify method.

gabarito.Spy( fn )
lib/gabarito.js:1296
Parameters:
  • fn <Function>

    The function to spy on

Index

Methods

handler.noCalls( [msg] )
lib/gabarito.js:1355

Relays the noCalls call to the spy instance.

Parameters:
  • [msg] <String>
handler.reset( )
lib/gabarito.js:1371

Relays the reset call to the spy instance.

gabarito.SpyVerifier handler.verify( [msg] )
lib/gabarito.js:1339

Relays the verify call to the spy instance.

Parameters:
  • [msg] <String>

noCalls( [msg] )
lib/gabarito.js:1421

Throws an error if a call was made

Parameters:
  • [msg] <String>
static Function on( fn )
lib/gabarito.js:1385

Creates a spy instance and returns its handler

Parameters:
  • fn <Function>

    The function to spy on


Returns: <Function>

Returns the handler function from the spy instance

reset( )
lib/gabarito.js:1436

Removes all recorded calls from the instance

gabarito.SpyVerifier verify( [msg] )
lib/gabarito.js:1402

Returns a spy verifier if a call was made

Parameters:
  • [msg] <String>

Properties

handler <Function>
lib/gabarito.js:1313

The handler function that relays all the calls, this is the actual function that should be used instead of the real one.