UNPKG

assertthat

Version:
27 lines (26 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertStringIsNotContainingAnyOfIterable = void 0; const errors_1 = require("../../errors"); const assertStringIsNotContainingString_1 = require("./assertStringIsNotContainingString"); const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint"); const defekt_1 = require("defekt"); const assertStringIsNotContainingAnyOfIterable = function (actual, iterable) { const containedItems = new Set(); for (const item of iterable) { const result = (0, assertStringIsNotContainingString_1.assertStringIsNotContainingString)(actual, item); if (result.hasError()) { containedItems.add(item); } } if (containedItems.size === 0) { return (0, defekt_1.value)(); } return (0, defekt_1.error)(new errors_1.AssertionFailed({ message: 'The string contains one or more of the sub-strings in the iterable.', actual: (0, prettyPrint_1.prettyPrint)(actual), expected: `To not contain any of:\n${(0, prettyPrint_1.prettyPrint)(iterable)}`, diff: `These sub-strings are contained, but should not be:\n${(0, prettyPrint_1.prettyPrint)(containedItems)}` })); }; exports.assertStringIsNotContainingAnyOfIterable = assertStringIsNotContainingAnyOfIterable;