archunit
Version:
ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app
27 lines • 1.45 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResultFactory = void 0;
const color_utils_1 = require("./color-utils");
class ResultFactory {
static result(shouldNotPass, violations) {
if (violations.length > 0) {
const violationSummary = violations.length === 1
? color_utils_1.ColorUtils.formatErrorSummary('Architecture rule failed with 1 violation:')
: color_utils_1.ColorUtils.formatErrorSummary(`Architecture rule failed with ${violations.length} violations:`);
const violationDetails = violations
.map((violation, index) => `${color_utils_1.ColorUtils.formatViolationNumber(`${index + 1}.`)} ${violation.message}`)
.join('\n\n');
const info = `${violationSummary}\n\n${violationDetails}`;
return { pass: false, message: () => info };
}
const successMessage = shouldNotPass
? color_utils_1.ColorUtils.formatSuccess('Architecture rule validation passed (expected to not pass)')
: color_utils_1.ColorUtils.formatSuccess('Architecture rule validation passed');
return { pass: true, message: () => successMessage };
}
static error(message) {
return { pass: false, message: () => color_utils_1.ColorUtils.redBold(`Error: ${message}`) };
}
}
exports.ResultFactory = ResultFactory;
//# sourceMappingURL=result-factory.js.map
;