Implement tests to check the limit error is the expected one

This commit is contained in:
Daniel García Aubert
2019-01-30 15:15:07 +01:00
parent 86f313ec52
commit d5af1bd9a2
2 changed files with 140 additions and 9 deletions
+11 -9
View File
@@ -142,16 +142,18 @@ function validateResponseBody(response, expected) {
function validateResponseStatus(response, expected) {
var status = expected.status || expected.statusCode;
const message = colorize('[red]{Invalid response status code.}\n' +
' Expected: [green]{' + status + '}\n' +
' Got: [red]{' + response.statusCode + '}\n' +
' Body: ' + response.body);
// Assert response status
if (typeof status === 'number') {
if (response.statusCode !== status) {
return new Error(colorize(
'[red]{Invalid response status code.}\n' +
' Expected: [green]{' + status + '}\n' +
' Got: [red]{' + response.statusCode + '}\n' +
' Body: ' + response.body)
);
}
if (typeof status === 'number' && response.statusCode !== status) {
return new Error(message);
}
if (Array.isArray(status) && !status.includes(response.statusCode)) {
return new Error(message);
}
}