testing
@prismatic-io/spectral › "testing"
#
Index#
Interfaces#
Functions#
Object literals#
FunctionsConst
getAuthorizationMethods#
▸ getAuthorizationMethods(except?
: AuthorizationMethod[]): AuthorizationMethod[]
Return listing of available authorization methods. If except is provided the returned list will be any authorization methods not in that list.
Parameters:
Name | Type |
---|---|
except? | AuthorizationMethod[] |
Returns: AuthorizationMethod[]
Const
invoke#
▸ invoke‹TReturn›(action
: ActionDefinition | Record‹string, ActionDefinition›, params
: ActionInputParameters, context?
: Partial‹ActionContext›): Promise‹InvokeResult‹TReturn››
Invokes specified ActionDefinition perform function using supplied params and optional context. Accepts a generic type matching PerformReturn as a convenience to avoid extra casting within test methods. Returns an InvokeResult containing both the action result and a mock logger for asserting logging.
Type parameters:
▪ TReturn: PerformReturn
Parameters:
Name | Type |
---|---|
action | ActionDefinition | Record‹string, ActionDefinition› |
params | ActionInputParameters |
context? | Partial‹ActionContext› |
Returns: Promise‹InvokeResult‹TReturn››
Const
loggerMock#
▸ loggerMock(): ActionLogger
Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
Returns: ActionLogger
#
Object literalsConst
credentials#
#
▪ credentials: objectUtility functions to generate the different types of Credentials.
#
apiKey▸ apiKey(key
: string): ApiKeyCredential
Return a ApiKeyCredential assembled from provided key.
Parameters:
Name | Type |
---|---|
key | string |
Returns: ApiKeyCredential
#
apiKeySecret▸ apiKeySecret(key
: string, secret
: string): ApiKeySecretCredential
Return a ApiKeySecretCredential assembled from provided key and secret.
Parameters:
Name | Type |
---|---|
key | string |
secret | string |
Returns: ApiKeySecretCredential
#
basic▸ basic(username
: string, password
: string): BasicCredential
Return a BasicCredential assembled from provided username and password.
Parameters:
Name | Type |
---|---|
username | string |
password | string |
Returns: BasicCredential
#
generate▸ generate(method
: AuthorizationMethod): Credential
Returns an arbitrary Credential using method. Generally used for testing negative support cases.
Parameters:
Name | Type |
---|---|
method | AuthorizationMethod |
Returns: Credential
#
oauth2▸ oauth2(token
: string, redirectUri
: string): OAuth2Credential
Return a OAuth2Credential assembled from provided token and optional redirectUri.
Parameters:
Name | Type | Default |
---|---|---|
token | string | - |
redirectUri | string | "" |
Returns: OAuth2Credential
#
oauth2ClientCredentials▸ oauth2ClientCredentials(token
: string): OAuth2Credential
Return a OAuth2Credential assembled from provided token.
Parameters:
Name | Type |
---|---|
token | string |
Returns: OAuth2Credential
#
privateKey▸ privateKey(username
: string, privateKey
: string): PrivateKeyCredential
Return a PrivateKeyCredential assembled from provided username and privateKey.
Parameters:
Name | Type |
---|---|
username | string |
privateKey | string |
Returns: PrivateKeyCredential