From a1b36933d866fc6f0e7fbdeee7e60eaffd924694 Mon Sep 17 00:00:00 2001 From: lucasfcosta Date: Mon, 2 Jan 2017 17:27:19 -0200 Subject: [PATCH] Fix set iterableToString test on IE11 --- lib/sinon/typeOf.js | 10 +++------- package.json | 3 ++- test/util/core/iterable-to-string-test.js | 8 +++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/sinon/typeOf.js b/lib/sinon/typeOf.js index 5bf6af4f4..2312f6d25 100644 --- a/lib/sinon/typeOf.js +++ b/lib/sinon/typeOf.js @@ -8,12 +8,8 @@ */ "use strict"; +var type = require("type-detect"); + module.exports = function typeOf(value) { - if (value === null) { - return "null"; - } else if (value === undefined) { - return "undefined"; - } - var string = Object.prototype.toString.call(value); - return string.substring(8, string.length - 1).toLowerCase(); + return type(value).toLowerCase(); }; diff --git a/package.json b/package.json index e59c7a4f9..094bc6a74 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "native-promise-only": "^0.8.1", "path-to-regexp": "^1.7.0", "samsam": "^1.1.3", - "text-encoding": "0.6.2" + "text-encoding": "0.6.2", + "type-detect": "^4.0.0" }, "devDependencies": { "browserify": "^13.0.0", diff --git a/test/util/core/iterable-to-string-test.js b/test/util/core/iterable-to-string-test.js index 3c32bb517..5bee0c9f1 100644 --- a/test/util/core/iterable-to-string-test.js +++ b/test/util/core/iterable-to-string-test.js @@ -32,7 +32,13 @@ describe("util/core/iterable-to-string", function () { if (typeof Set === "function") { it("returns an String representation of Set objects", function () { - var set = new Set([1, "one", true, undefined, null]); + var set = new Set(); + set.add(1); + set.add("one"); + set.add(true); + set.add(undefined); + set.add(null); + var expected = "1,'one',true,undefined,null"; assert.equals(iterableToString(set), expected);