Preset
Extends:
Presets are a quick way to add common response configuration and avoid duplicating it through all fixtures when configuring server response.
Configuration itself is, like the fixtures, based on ResponseConfigurator methods.
Constructor Summary
Public Constructor | ||
public |
constructor(server: Server, name: String, preset: Object) Create a new preset instance that can be configured in the same manner than a regular fixture |
version 1.0.0 since 2.0.0 |
Member Summary
Public Members | ||
public |
name: * |
Method Summary
Public Methods | ||
public |
Register/update the preset in the global pool. |
version 1.0.0 since 2.2.0 |
public |
Remove the preset from the server's instance pool If the preset is also globally registered, it won't be removed from the global pool |
version 1.0.0 since 2.2.0 |
public |
unregister(): Preset Unregister the preset from the global pool. |
version 1.0.0 since 2.2.0 |
Private Methods | ||
private |
Presets can only handle a default response |
version 1.0.0 since 2.0.0 |
Inherited Summary
From class ResponseConfigurator | ||
public get |
Sugar for chaining |
version 1.0.0 since 2.0.0 |
public get |
Sugar for chaining |
version 1.0.0 since 2.0.0 |
public |
Stores the server instance |
since 2.0.0 |
private |
Default response for fixture or preset. |
since 2.0.0 |
private |
Allowed response keys |
since 2.0.0 |
public |
Set the after callback |
version 1.0.0 since 2.0.0 |
public |
Set the before callback |
version 1.0.0 since 2.0.0 |
public |
body(body: String | Function): ResponseConfigurator Set the response body |
version 1.0.0 since 2.0.0 |
public |
delay(delay: Boolean | Number): ResponseConfigurator Set the time the server will wait before sending back response |
version 1.0.0 since 2.0.0 |
public |
header(name: String, content: String, append: Boolean): ResponseConfigurator Set a specific header value |
version 1.0.0 since 2.2.0 |
public |
headers(headers: Object | Headers | Boolean): ResponseConfigurator One time setter for all headers |
version 1.0.1 since 2.0.0 |
public |
pattern(pattern: String): ResponseConfigurator Set the pattern that will be used to match the request |
version 1.0.0 since 2.0.0 |
public |
Set the response parameters based on the object provided |
version 1.0.0 since 2.0.0 |
public |
status(status: Number): ResponseConfigurator Set the response status |
version 1.0.0 since 2.0.0 |
public |
statusText(text: String): ResponseConfigurator Set the response status text |
version 1.0.0 since 2.0.0 |
public |
wrapper(wrapper: Function | Boolean): ResponseConfigurator Set the response body wrapper |
version 1.0.0 since 2.0.0 |
private abstract |
|
Public Constructors
public constructor(server: Server, name: String, preset: Object) version 1.0.0 since 2.0.0 source
Create a new preset instance that can be configured in the same manner than a regular fixture
Override:
ResponseConfigurator#constructorPublic Members
public name: * source
Public Methods
public register(): Preset version 1.0.0 since 2.2.0 source
Register/update the preset in the global pool. This made the preset available into all server's instances created from the registration
public remove(): Preset version 1.0.0 since 2.2.0 source
Remove the preset from the server's instance pool
If the preset is also globally registered, it won't be removed from the global pool
public unregister(): Preset version 1.0.0 since 2.2.0 source
Unregister the preset from the global pool.