Module: models/inMemoryImpostersRepository

An abstraction for loading imposters from in-memory

Source:

Methods

add(stub) → {Object}

Adds a new stub

Parameters:
Name Type Description
stub Object

the stub to add

Source:
Returns:
  • the promise
Type
Object

add(imposter) → {Object}

Adds a new imposter

Parameters:
Name Type Description
imposter Object

the imposter to add

Source:
Returns:
  • the promise
Type
Object

addRequest(request) → {Object}

Adds a request for the imposter

Parameters:
Name Type Description
request Object

the request

Source:
Returns:
  • the promise
Type
Object

all() → {Object}

Gets all imposters

Source:
Returns:
  • all imposters keyed by port
Type
Object

del(id) → {Object}

Deletes the imposter at the given id

Parameters:
Name Type Description
id Number

the id (e.g. the port)

Source:
Returns:
  • the deletion promise
Type
Object

deleteAll() → {Object}

Deletes all imposters

Source:
Returns:
  • the deletion promise
Type
Object

deleteAtIndex(index) → {Object}

Deletes the stub at the given index

Parameters:
Name Type Description
index Number

the index of the stub to delete

Source:
Returns:
  • the promise
Type
Object

deleteSavedProxyResponses() → {Object}

Removes the saved proxy responses

Source:
Returns:
  • Promise
Type
Object

deleteSavedRequests(request) → {Object}

Clears the saved requests list

Parameters:
Name Type Description
request Object

the request

Source:
Returns:
  • Promise
Type
Object

exists(id) → {boolean}

Returns whether an imposter at the given id exists or not

Parameters:
Name Type Description
id Number

the id (e.g. the port)

Source:
Returns:
Type
boolean

first(filter, startIndex) → {Object}

Returns the first stub whose predicates match the filter, or a default one if none match

Parameters:
Name Type Default Description
filter function

the filter function

startIndex Number 0

the index to to start searching

Source:
Returns:
Type
Object

get(id) → {Object}

Gets the imposter by id

Parameters:
Name Type Description
id Number

the id of the imposter (e.g. the port)

Source:
Returns:
  • the imposter
Type
Object

insertAtIndex(stub, index) → {Object}

Inserts a new stub at the given index

Parameters:
Name Type Description
stub Object

the stub to insert

index Number

the index to add the stub at

Source:
Returns:
  • the promise
Type
Object

loadRequests() → {Object}

Returns the saved requests for the imposter

Source:
Returns:
  • the promise resolving to the array of requests
Type
Object

overwriteAll(newStubs) → {Object}

Overwrites the list of stubs with a new list

Parameters:
Name Type Description
newStubs Object

the new list of stubs

Source:
Returns:
  • the promise
Type
Object

overwriteAtIndex(newStub, index) → {Object}

Overwrites the stub at the given index with the new stub

Parameters:
Name Type Description
newStub Object

the new stub

index Number

the index of the old stuib

Source:
Returns:
  • the promise
Type
Object

stopAllSync()

Deletes all imposters synchronously; used during shutdown

Source:

stubsFor(id) → {Object}

Returns the stub repository for the given id

Parameters:
Name Type Description
id Number

the imposter's id

Source:
Returns:
  • the stub repository
Type
Object

toJSON(options) → {Object}

Returns a JSON-convertible representation

Parameters:
Name Type Description
options Object

The formatting options

Properties
Name Type Description
debug Boolean

If true, includes debug information

Source:
Returns:
  • the promise resolving to the JSON object
Type
Object

(inner) create() → {Object}

Creates the repository

Source:
Returns:
Type
Object

(inner) createStubsRepository() → {Object}

Creates the stubs repository for a single imposter

Source:
Returns:
Type
Object