borders-rest-client
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -65,2 +65,5 @@ 'use strict'; | ||
function validateResponseProperties(response) { | ||
if (!response || !response.status) { | ||
throw new Error('The response property "status" is required'); | ||
} | ||
var _iteratorNormalCompletion2 = true; | ||
@@ -128,5 +131,5 @@ var _didIteratorError2 = false; | ||
const stubRequest = (method, request, response) => { | ||
const stubRequest = (method, request, response = { status: 200 }) => { | ||
validateResponseProperties(response); | ||
validateHeaders(response); | ||
validateResponseProperties(response); | ||
validateRequestProperties(request); | ||
@@ -146,3 +149,5 @@ | ||
}, request)); | ||
if (!response) { | ||
throw new _error.RestError(`No response defined for rest call "${method}: ${request.path}"`); | ||
} | ||
if (response.status >= 400) { | ||
@@ -149,0 +154,0 @@ throw new _error.RestStatusError(undefined, response.status, response); |
{ | ||
"name": "borders-rest-client", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Specification for system border rest-client", | ||
@@ -5,0 +5,0 @@ "author": "Actano GmbH (https://rplan.com/)", |
@@ -8,3 +8,3 @@ // eslint-disable-next-line import/no-extraneous-dependencies | ||
import { STUB_CALL } from '../test-commands/stub-call' | ||
import { RestStatusError } from '../error' | ||
import { RestError, RestStatusError } from '../error' | ||
@@ -30,2 +30,5 @@ const supportedResponseProperties = [ | ||
function validateResponseProperties(response) { | ||
if (!response || !response.status) { | ||
throw new Error('The response property "status" is required') | ||
} | ||
for (const responseProperty of Object.keys(response)) { | ||
@@ -51,5 +54,5 @@ if (!supportedResponseProperties.includes(responseProperty)) { | ||
const stubRequest = (method, request, response) => { | ||
const stubRequest = (method, request, response = { status: 200 }) => { | ||
validateResponseProperties(response) | ||
validateHeaders(response) | ||
validateResponseProperties(response) | ||
validateRequestProperties(request) | ||
@@ -71,3 +74,5 @@ | ||
}) | ||
if (!response) { | ||
throw new RestError(`No response defined for rest call "${method}: ${request.path}"`) | ||
} | ||
if (response.status >= 400) { | ||
@@ -74,0 +79,0 @@ throw new RestStatusError(undefined, response.status, response) |
41100
1195