UNPKG

assertthat

Version:
25 lines (24 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertSetIsContainingAnyOfIterable = void 0; const errors_1 = require("../../errors"); const assertSetIsContainingItem_1 = require("./assertSetIsContainingItem"); const dispel_1 = require("../../dispel/dispel"); const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint"); const defekt_1 = require("defekt"); const assertSetIsContainingAnyOfIterable = function (actual, iterable) { const dispelledActual = (0, dispel_1.dispel)(actual); const dispelledExpected = (0, dispel_1.dispel)(iterable); for (const item of dispelledExpected) { const result = (0, assertSetIsContainingItem_1.assertSetIsContainingItem)(dispelledActual, item); if (result.hasValue()) { return (0, defekt_1.value)(); } } return (0, defekt_1.error)(new errors_1.AssertionFailed({ message: 'The set does not contain any of the expected items.', actual: (0, prettyPrint_1.prettyPrint)(dispelledActual), expected: `To contain any of:\n${(0, prettyPrint_1.prettyPrint)(dispelledExpected)}` })); }; exports.assertSetIsContainingAnyOfIterable = assertSetIsContainingAnyOfIterable;