From 0fdb05fd720f96b063a08ed0a083f8500050c701 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Mon, 28 Nov 2022 18:08:32 +0100 Subject: [PATCH] Remove unused custom formatter --- lib/sinon/util/core/format.js | 22 ---------------------- test/util/core/format-test.js | 33 --------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 lib/sinon/util/core/format.js delete mode 100644 test/util/core/format-test.js diff --git a/lib/sinon/util/core/format.js b/lib/sinon/util/core/format.js deleted file mode 100644 index 033c145d7..000000000 --- a/lib/sinon/util/core/format.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -var inspect = require("util").inspect; -var customFormatter; - -function format() { - if (customFormatter) { - return customFormatter.apply(null, arguments); - } - - return inspect.apply(inspect, arguments); -} - -format.setFormatter = function (aCustomFormatter) { - if (typeof aCustomFormatter !== "function") { - throw new Error("format.setFormatter must be called with a function"); - } - - customFormatter = aCustomFormatter; -}; - -module.exports = format; diff --git a/test/util/core/format-test.js b/test/util/core/format-test.js deleted file mode 100644 index 6eaed189c..000000000 --- a/test/util/core/format-test.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; - -var referee = require("@sinonjs/referee"); -var sinon = require("../../../lib/sinon"); -var format = require("../../../lib/sinon/util/core/format"); -var assert = referee.assert; - -describe("util/core/format", function () { - describe("format.setFormatter", function () { - it("sets custom formatter", function () { - format.setFormatter(function () { - return "formatted"; - }); - assert.equals(format("Hey"), "formatted"); - }); - - it("throws if custom formatter is not a function", function () { - assert.exception( - function () { - format.setFormatter("foo"); - }, - { - message: - "format.setFormatter must be called with a function", - } - ); - }); - - it("exposes method on sinon", function () { - assert.equals(sinon.setFormatter, format.setFormatter); - }); - }); -});