Module: models/inMemoryImpostersRepository

An abstraction for loading imposters from in-memory

Source:

Methods

(async) add(stub) → {Object}

Adds a new stub

Parameters:
Name Type Description
stub Object

the stub to add

Source:
Returns:
  • the promise
Type
Object

(async) add(imposter) → {Object}

Adds a new imposter

Parameters:
Name Type Description
imposter Object

the imposter to add

Source:
Returns:
  • the promise
Type
Object

(async) addRequest(request) → {Object}

Adds a request for the imposter

Parameters:
Name Type Description
request Object

the request

Source:
Returns:
  • the promise
Type
Object

(async) all() → {Object}

Gets all imposters

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

(async) 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

(async) deleteAll() → {Object}

Deletes all imposters

Source:
Returns:
  • the deletion promise
Type
Object

(async) 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

(async) deleteSavedProxyResponses() → {Object}

Removes the saved proxy responses

Source:
Returns:
  • Promise
Type
Object

(async) deleteSavedRequests(request) → {Object}

Clears the saved requests list

Parameters:
Name Type Description
request Object

the request

Source:
Returns:
  • Promise
Type
Object

(async) 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

(async) 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

(async) 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

(async) 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

(async) loadAll() → {Object}

Called at startup to load saved imposters.
Does nothing for in memory repository

Source:
Returns:
  • a promise
Type
Object

(async) loadRequests() → {Object}

Returns the saved requests for the imposter

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

(async) 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

(async) 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

(async) 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