assertthat
Version:
assertthat provides fluent TDD.
22 lines (21 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertStringIsContainingAnyOfIterable = void 0;
const errors_1 = require("../../errors");
const assertStringIsContainingString_1 = require("./assertStringIsContainingString");
const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint");
const defekt_1 = require("defekt");
const assertStringIsContainingAnyOfIterable = function (actual, iterable) {
for (const item of iterable) {
const result = (0, assertStringIsContainingString_1.assertStringIsContainingString)(actual, item);
if (result.hasValue()) {
return (0, defekt_1.value)();
}
}
return (0, defekt_1.error)(new errors_1.AssertionFailed({
message: 'The string does not contain any of the expected sub-strings.',
actual: (0, prettyPrint_1.prettyPrint)(actual),
expected: `To contain any of:\n${(0, prettyPrint_1.prettyPrint)(iterable)}`
}));
};
exports.assertStringIsContainingAnyOfIterable = assertStringIsContainingAnyOfIterable;