UNPKG

@case-contract-testing/case

Version:

Next-generation contract testing suite

24 lines (23 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.whyNotAnObject = exports.isObject = void 0; const results_1 = require("../../../entities/results"); 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, results_1.actualToString)(actual)}' is not an Object, or it is inappropriately called.`; }; exports.whyNotAnObject = whyNotAnObject;