assertthat
Version:
assertthat provides fluent TDD.
25 lines (24 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.compareErrors = void 0;
const compareObjects_1 = require("../forObjects/compareObjects");
const LessShittyError_1 = require("../../types/LessShittyError");
const EqualDiff_1 = require("../../diffs/EqualDiff");
const ErrorDiff_1 = require("../../diffs/forErrors/ErrorDiff");
const compareErrors = function (actual, expected) {
const actualLessShittyError = (0, LessShittyError_1.makeErrorLessShitty)({
error: actual
});
const expectedLessShittyError = (0, LessShittyError_1.makeErrorLessShitty)({
error: expected
});
const objectDiff = (0, compareObjects_1.compareObjects)(actualLessShittyError, expectedLessShittyError);
if ((0, EqualDiff_1.isEqualDiff)(objectDiff)) {
return (0, EqualDiff_1.equalDiff)({ value: actual });
}
return (0, ErrorDiff_1.errorDiff)({
cost: objectDiff.cost,
objectDiff
});
};
exports.compareErrors = compareErrors;