From fb8b3d72a85dc8fb0547f859baf3f03a22a039f7 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Wed, 19 Jan 2022 14:47:46 +0100 Subject: [PATCH] Run Prettier --- lib/sinon/stub.js | 21 ++++++++++--- test/shared-spy-stub-everything-tests.js | 40 ++++++++++++------------ 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/lib/sinon/stub.js b/lib/sinon/stub.js index 8712f9d8b..a9b324e6a 100644 --- a/lib/sinon/stub.js +++ b/lib/sinon/stub.js @@ -151,22 +151,33 @@ stub.createStubInstance = function (constructor, overrides) { }; function assertValidPropertyDescriptor(descriptor, property) { - if (!descriptor || !property) { + if (!descriptor || !property) { return; } if (!descriptor.configurable && !descriptor.writable) { - throw new TypeError(`Descriptor for property ${property} is non-configurable and non-writable`); + throw new TypeError( + `Descriptor for property ${property} is non-configurable and non-writable` + ); } if ((descriptor.get || descriptor.set) && !descriptor.configurable) { - throw new TypeError(`Descriptor for accessor property ${property} is non-configurable`); + throw new TypeError( + `Descriptor for accessor property ${property} is non-configurable` + ); } if (isDataDescriptor(descriptor) && !descriptor.writable) { - throw new TypeError(`Descriptor for data property ${property} is non-writable`); + throw new TypeError( + `Descriptor for data property ${property} is non-writable` + ); } } function isDataDescriptor(descriptor) { - return !descriptor.value && !descriptor.writable && !descriptor.set && !descriptor.get; + return ( + !descriptor.value && + !descriptor.writable && + !descriptor.set && + !descriptor.get + ); } /*eslint-disable no-use-before-define*/ diff --git a/test/shared-spy-stub-everything-tests.js b/test/shared-spy-stub-everything-tests.js index 1d560c802..2253f154e 100644 --- a/test/shared-spy-stub-everything-tests.js +++ b/test/shared-spy-stub-everything-tests.js @@ -154,48 +154,48 @@ module.exports = function shared(createSpyOrStub) { it("throws on data property descriptors that are not writable or configurable", function () { var myObj = {}; - Object.defineProperty(myObj, 'ignoreme', { + Object.defineProperty(myObj, "ignoreme", { writable: false, - configurable: false + configurable: false, }); assert.exception(function () { - createSpyOrStub(myObj, "ignoreme"); - }, - new TypeError('Descriptor for property ignoreme is non-configurable and non-writable') - ); + createSpyOrStub(myObj, "ignoreme"); + }, new TypeError( + "Descriptor for property ignoreme is non-configurable and non-writable" + )); }); it("throws on accessor property descriptors that are not configurable", function () { var myObj = {}; - Object.defineProperty(myObj, 'ignoreme', { - get: function(key) { + Object.defineProperty(myObj, "ignoreme", { + get: function (key) { return this[key]; }, - set: function(key, val) { + set: function (key, val) { this[key] = val; }, - configurable: false + configurable: false, }); assert.exception(function () { - createSpyOrStub(myObj, "ignoreme"); - }, - new TypeError('Descriptor for accessor property ignoreme is non-configurable') - ); + createSpyOrStub(myObj, "ignoreme"); + }, new TypeError( + "Descriptor for accessor property ignoreme is non-configurable" + )); }); it("throws on data descriptors that are not stubbable", function () { var myObj = {}; - Object.defineProperty(myObj, 'ignoreme', { + Object.defineProperty(myObj, "ignoreme", { writable: false, - configurable: false + configurable: false, }); assert.exception(function () { - createSpyOrStub(myObj, "ignoreme"); - }, - new TypeError('Descriptor for data property ignoreme is non-writable') - ); + createSpyOrStub(myObj, "ignoreme"); + }, new TypeError( + "Descriptor for data property ignoreme is non-writable" + )); }); };