An abstraction for loading imposters from in-memory
Methods
(async) add(stub) → {Object}
Adds a new stub
Parameters:
Name | Type | Description |
---|---|---|
stub |
Object | the stub to add |
Returns:
- the promise
- Type
- Object
(async) add(imposter) → {Object}
Adds a new imposter
Parameters:
Name | Type | Description |
---|---|---|
imposter |
Object | the imposter to add |
Returns:
- the promise
- Type
- Object
(async) addRequest(request) → {Object}
Adds a request for the imposter
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | the request |
Returns:
- the promise
- Type
- Object
(async) all() → {Object}
Gets all imposters
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) |
Returns:
- the deletion promise
- Type
- Object
(async) deleteAll() → {Object}
Deletes all imposters
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 |
Returns:
- the promise
- Type
- Object
(async) deleteSavedProxyResponses() → {Object}
Removes the saved proxy responses
Returns:
- Promise
- Type
- Object
(async) deleteSavedRequests(request) → {Object}
Clears the saved requests list
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | the request |
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) |
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 |
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) |
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 |
Returns:
- the promise
- Type
- Object
(async) loadAll() → {Object}
Called at startup to load saved imposters.
Does nothing for in memory repository
Returns:
- a promise
- Type
- Object
(async) loadRequests() → {Object}
Returns the saved requests for the imposter
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 |
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 |
Returns:
- the promise
- Type
- Object
stopAllSync()
Deletes all imposters synchronously; used during shutdown
stubsFor(id) → {Object}
Returns the stub repository for the given id
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | the imposter's id |
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
|
Returns:
- the promise resolving to the JSON object
- Type
- Object
(inner) create() → {Object}
Creates the repository
Returns:
- Type
- Object
(inner) createStubsRepository() → {Object}
Creates the stubs repository for a single imposter
Returns:
- Type
- Object