@contract-case/case-core
Version:
Core functionality for the ContractCase contract testing suite
24 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.whyNotAnObject = exports.isObject = void 0;
const case_plugin_base_1 = require("@contract-case/case-plugin-base");
const isObject = (actual) => // the return type here is technically not correct
typeof actual === 'object' &&
actual === Object(actual) &&
!Array.isArray(actual) &&
actual != null;
exports.isObject = isObject;
const whyNotAnObject = (actual) => {
if (actual == null) {
return 'Expected an object, but it was null or undefined';
}
if (typeof actual !== 'object') {
return `Expected an object, but the type was '${typeof actual}' instead`;
}
if (Array.isArray(actual)) {
return 'Expected an object, but it was an array';
}
return `If you are seeing this message, there is a bug in whyNotAnObject, where it can't see a reason that '${(0, case_plugin_base_1.actualToString)(actual)}' is not an Object, or it is inappropriately called.`;
};
exports.whyNotAnObject = whyNotAnObject;
//# sourceMappingURL=objectTests.js.map