approvals
Version:
Approval Tests Library - Capturing Human Intelligence
29 lines (28 loc) • 796 B
JavaScript
;
class DiffReporterAggregate {
constructor(reporters) {
this.reporters = reporters;
this.name = `DiffReporterAggregate [${reporters.map((item) => item.name).join(", ")}]`;
}
getReporter(file) {
for (const reporter of this.reporters) {
if (reporter.canReportOn(file)) {
return reporter;
}
}
return null;
}
canReportOn(file) {
return !!this.getReporter(file);
}
report(approved, received, options) {
const reporter = this.getReporter(received);
if (reporter) {
reporter.report(approved, received, options);
}
else {
throw new Error("No reporter found!");
}
}
}
module.exports = DiffReporterAggregate;