UNPKG

assertthat

Version:
26 lines (25 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertObjectIsNotAtMostObject = void 0; const errors_1 = require("../../errors"); const compareObjects_1 = require("../../comparisons/forObjects/compareObjects"); const dispel_1 = require("../../dispel/dispel"); const EqualDiff_1 = require("../../diffs/EqualDiff"); const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint"); const defekt_1 = require("defekt"); const assertObjectIsNotAtMostObject = function (actual, expected) { const dispelledActual = (0, dispel_1.dispel)(actual); const dispelledExpected = (0, dispel_1.dispel)(expected); const diff = (0, compareObjects_1.compareObjects)(dispelledActual, dispelledExpected); if (!(0, EqualDiff_1.isEqualDiff)(diff) && (Object.keys(diff.additions).length > 0 || Object.keys(diff.changes).length > 0)) { return (0, defekt_1.value)(); } return (0, defekt_1.error)(new errors_1.AssertionFailed({ message: 'The actual object is entirely contained in the expected object.', actual: (0, prettyPrint_1.prettyPrint)(dispelledActual), expected: `To not be entirely contained in:\n${(0, prettyPrint_1.prettyPrint)(dispelledExpected)}` })); }; exports.assertObjectIsNotAtMostObject = assertObjectIsNotAtMostObject;