Skip to content

Commit

Permalink
Merge 2ac8cb3 into c03a0f9
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed May 21, 2019
2 parents c03a0f9 + 2ac8cb3 commit 20c093d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/next/test/integration/validateMessage.test.js
Expand Up @@ -299,7 +299,7 @@ describe('validateMessage', () => {
assert.propertyVal(
result.statusCode.results[0],
'message',
'Real and expected data does not match.'
`Status code is '400' instead of '200'`
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/next/test/unit/units/validateStatusCode.test.js
Expand Up @@ -64,7 +64,7 @@ describe('validateStatusCode', () => {
assert.propertyVal(
result.results[0],
'message',
'Real and expected data does not match.'
`Status code is '200' instead of '400'`
);
});
});
Expand Down
12 changes: 11 additions & 1 deletion lib/next/units/validateStatusCode.js
Expand Up @@ -10,13 +10,23 @@ const APIARY_STATUS_CODE_TYPE = 'text/vnd.apiary.status-code';
function validateStatusCode(real, expected) {
const validator = new TextDiff(real.statusCode, expected.statusCode);
const rawData = validator.validate();
const results = validator.evaluateOutputToResults();

return {
validator: 'TextDiff',
realType: APIARY_STATUS_CODE_TYPE,
expectedType: APIARY_STATUS_CODE_TYPE,
rawData,
results: validator.evaluateOutputToResults()
results: results.map((result) =>
Object.assign({}, result, {
message:
result.message === 'Real and expected data does not match.'
? `Status code is '${real.statusCode}' instead of '${
expected.statusCode
}'`
: result.message
})
)
};
}

Expand Down

0 comments on commit 20c093d

Please sign in to comment.