Skip to content

Commit

Permalink
Rename util
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Mar 9, 2020
1 parent 4b55c62 commit 49abbad
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 49abbad

Please sign in to comment.