assertthat
Version:
assertthat provides fluent TDD.
25 lines (24 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertSetIsNotContainingAllOfIterable = 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 assertSetIsNotContainingAllOfIterable = 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.hasError()) {
return (0, defekt_1.value)();
}
}
return (0, defekt_1.error)(new errors_1.AssertionFailed({
message: 'The set contains all items in the iterable.',
actual: (0, prettyPrint_1.prettyPrint)(dispelledActual),
expected: `To not contain all of:\n${(0, prettyPrint_1.prettyPrint)(dispelledExpected)}`
}));
};
exports.assertSetIsNotContainingAllOfIterable = assertSetIsNotContainingAllOfIterable;