Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

deprecated.test.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* eslint-disable no-console */
  2. "use strict";
  3. var assert = require("@sinonjs/referee-sinon").assert;
  4. var sinon = require("@sinonjs/referee-sinon").sinon;
  5. var deprecated = require("./deprecated");
  6. var msg = "test";
  7. describe("deprecated", function() {
  8. describe("defaultMsg", function() {
  9. it("should return a string", function() {
  10. assert.equals(
  11. deprecated.defaultMsg("sinon", "someFunc"),
  12. "sinon.someFunc is deprecated and will be removed from the public API in a future version of sinon."
  13. );
  14. });
  15. });
  16. describe("printWarning", function() {
  17. beforeEach(function() {
  18. sinon.replace(process, "emitWarning", sinon.fake());
  19. });
  20. afterEach(sinon.restore);
  21. describe("when `process.emitWarning` is defined", function() {
  22. it("should call process.emitWarning with a msg", function() {
  23. deprecated.printWarning(msg);
  24. assert.calledOnceWith(process.emitWarning, msg);
  25. });
  26. });
  27. describe("when `process.emitWarning` is undefined", function() {
  28. beforeEach(function() {
  29. sinon.replace(console, "info", sinon.fake());
  30. sinon.replace(console, "log", sinon.fake());
  31. process.emitWarning = undefined;
  32. });
  33. afterEach(sinon.restore);
  34. describe("when `console.info` is defined", function() {
  35. it("should call `console.info` with a message", function() {
  36. deprecated.printWarning(msg);
  37. assert.calledOnceWith(console.info, msg);
  38. });
  39. });
  40. describe("when `console.info` is undefined", function() {
  41. it("should call `console.log` with a message", function() {
  42. console.info = undefined;
  43. deprecated.printWarning(msg);
  44. assert.calledOnceWith(console.log, msg);
  45. });
  46. });
  47. });
  48. });
  49. describe("wrap", function() {
  50. var method = sinon.fake();
  51. var wrapped;
  52. beforeEach(function() {
  53. wrapped = deprecated.wrap(method, msg);
  54. });
  55. it("should return a wrapper function", function() {
  56. assert.match(wrapped, sinon.match.func);
  57. });
  58. it("should assign the prototype of the passed method", function() {
  59. assert.equals(method.prototype, wrapped.prototype);
  60. });
  61. context("when the passed method has falsy prototype", function() {
  62. it("should not be assigned to the wrapped method", function() {
  63. method.prototype = null;
  64. wrapped = deprecated.wrap(method, msg);
  65. assert.match(wrapped.prototype, sinon.match.object);
  66. });
  67. });
  68. context("when invoking the wrapped function", function() {
  69. before(function() {
  70. sinon.replace(deprecated, "printWarning", sinon.fake());
  71. wrapped({});
  72. });
  73. it("should call `printWarning` before invoking", function() {
  74. assert.calledOnceWith(deprecated.printWarning, msg);
  75. });
  76. it("should invoke the passed method with the given arguments", function() {
  77. assert.calledOnceWith(method, {});
  78. });
  79. });
  80. });
  81. });