@sinonjs/commons
Advanced tools
Comparing version 1.7.2 to 1.8.0
# Changes | ||
## 1.8.0 | ||
- [`4282205`](https://github.com/sinonjs/commons/commit/4282205343a4dcde2a35ccf2a8c2094300dad369) | ||
Emit deprecationg warnings in node, and keep console info in browsers (mshaaban0) | ||
_Released on 2020-05-20._ | ||
## 1.7.2 | ||
@@ -4,0 +11,0 @@ |
@@ -49,11 +49,11 @@ /* eslint-disable no-console */ | ||
exports.printWarning = function(msg) { | ||
// Watch out for IE7 and below! :( | ||
/* istanbul ignore next */ | ||
if (typeof console !== "undefined") { | ||
if (console.info) { | ||
console.info(msg); | ||
} else { | ||
console.log(msg); | ||
} | ||
if (typeof process === "object" && process.emitWarning) { | ||
// Emit Warnings in Node | ||
process.emitWarning(msg); | ||
} else if (console.info) { | ||
console.info(msg); | ||
} else { | ||
console.log(msg); | ||
} | ||
}; |
@@ -22,6 +22,20 @@ /* eslint-disable no-console */ | ||
describe("printWarning", function() { | ||
describe("when `console` is defined", function() { | ||
beforeEach(function() { | ||
sinon.replace(process, "emitWarning", sinon.fake()); | ||
}); | ||
afterEach(sinon.restore); | ||
describe("when `process.emitWarning` is defined", function() { | ||
it("should call process.emitWarning with a msg", function() { | ||
deprecated.printWarning(msg); | ||
assert.calledOnceWith(process.emitWarning, msg); | ||
}); | ||
}); | ||
describe("when `process.emitWarning` is undefined", function() { | ||
beforeEach(function() { | ||
sinon.replace(console, "info", sinon.fake()); | ||
sinon.replace(console, "log", sinon.fake()); | ||
process.emitWarning = undefined; | ||
}); | ||
@@ -32,3 +46,3 @@ | ||
describe("when `console.info` is defined", function() { | ||
it("shoudl call `console.info` with a message", function() { | ||
it("should call `console.info` with a message", function() { | ||
deprecated.printWarning(msg); | ||
@@ -35,0 +49,0 @@ assert.calledOnceWith(console.info, msg); |
{ | ||
"name": "@sinonjs/commons", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Simple functions shared among the sinon end user libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44387
882