UNPKG

assertthat

Version:
21 lines (20 loc) 890 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertObjectIsInstanceOfClass = void 0; const errors_1 = require("../../errors"); const dispel_1 = require("../../dispel/dispel"); const prettyPrint_1 = require("../../prettyPrint/typeAware/prettyPrint"); const defekt_1 = require("defekt"); const assertObjectIsInstanceOfClass = function (actual, // eslint-disable-next-line @typescript-eslint/ban-types expected) { if (actual instanceof expected) { return (0, defekt_1.value)(); } return (0, defekt_1.error)(new errors_1.AssertionFailed({ message: 'The object is not an instance of the expected class.', actual: (0, prettyPrint_1.prettyPrint)((0, dispel_1.dispel)(actual)), expected: `To be an instance of:\n${expected.name}` })); }; exports.assertObjectIsInstanceOfClass = assertObjectIsInstanceOfClass;