Skip to content

Commit

Permalink
sinonjs#2226: Rename util
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Mar 9, 2020
1 parent 07a8f8c commit 170c99a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/sinon/stub.js
Expand Up @@ -6,7 +6,7 @@ var behaviors = require("./default-behaviors");
var createProxy = require("./proxy");
var functionName = require("@sinonjs/commons").functionName;
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var isNonExistentOwnProperty = require("./util/core/is-non-existent-own-property");
var isNonExistentProperty = require("./util/core/is-non-existent-property");
var spy = require("./spy");
var extend = require("./util/core/extend");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
Expand Down Expand Up @@ -69,8 +69,8 @@ function stub(object, property) {

throwOnFalsyObject.apply(null, arguments);

if (isNonExistentOwnProperty(object, property)) {
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
if (isNonExistentProperty(object, property)) {
throw new TypeError("Cannot stub non-existent property " + valueToString(property));
}

var actualDescriptor = getPropertyDescriptor(object, property);
Expand Down
7 changes: 0 additions & 7 deletions lib/sinon/util/core/is-non-existent-own-property.js

This file was deleted.

12 changes: 12 additions & 0 deletions lib/sinon/util/core/is-non-existent-property.js
@@ -0,0 +1,12 @@
"use strict";

/**
* @param {*} object
* @param {String} property
* @returns whether a prop exists in the prototype chain
*/
function isNonExistentProperty(object, property) {
return object && typeof property !== "undefined" && !(property in object);
}

module.exports = isNonExistentProperty;
2 changes: 1 addition & 1 deletion test/sandbox-test.js
Expand Up @@ -562,7 +562,7 @@ describe("Sandbox", function() {
function() {
sandbox.stub(object, Symbol());
},
{ message: "Cannot stub non-existent own property Symbol()" },
{ message: "Cannot stub non-existent property Symbol()" },
TypeError
);

Expand Down

0 comments on commit 170c99a

Please sign in to comment.