archunit
Version:
ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app
36 lines • 1.34 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyTestViolation = void 0;
const regex_factory_1 = require("../regex-factory");
/**
* Helper function to extract all pattern strings from filters
*/
function getFilterPatternStrings(filters) {
return filters.map((filter) => (0, regex_factory_1.getPatternString)(filter.regExp)).join(', ');
}
/**
* EmptyTestViolation represents a violation when no files are found that match the preconditions
* This helps detect tests that don't actually test anything because they match no files
*/
class EmptyTestViolation {
constructor(filters, customMessage, isNegated = false) {
let patternString = '';
if (filters.length > 0) {
if (typeof filters[0] === 'string') {
patternString = filters.join(',');
}
else {
patternString =
typeof filters === 'string'
? filters
: getFilterPatternStrings(filters);
}
}
this.filters = filters;
this.message =
customMessage || `No files found matching pattern(s): ${patternString}`;
this.isNegated = isNegated;
}
}
exports.EmptyTestViolation = EmptyTestViolation;
//# sourceMappingURL=EmptyTestViolation.js.map
;