UNPKG

sinon-test

Version:

<a href="CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>

32 lines (28 loc) 911 B
/** * Internal utilities for sinon-test */ "use strict"; /** * From version 3.1 Sinon uses factory methods for sandboxes and deprecates * sinon.sandbox. It - and its exports - will in time be removed/internalized, but * we can still support backwards compatibility easily. * See Sinon pull request #1515 */ function isOlderSinonVersion(sinonObj) { return ( typeof sinonObj.createSandbox === "undefined" && Boolean(sinonObj.sandbox) && typeof sinonObj.sandbox === "object" && typeof sinonObj.sandbox.create === "function" ); } exports.isPromise = function (object) { return typeof object === "object" && typeof object.then === "function"; }; exports.isSinon = function (obj) { var isObject = Boolean(obj) && typeof obj === "object"; return ( isObject && (isOlderSinonVersion(obj) || typeof obj.createSandbox === "function") ); };