Skip to content

Commit fb8b3d7

Browse files
committedJan 19, 2022
Run Prettier
1 parent 12a4593 commit fb8b3d7

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed
 

‎lib/sinon/stub.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,33 @@ stub.createStubInstance = function (constructor, overrides) {
151151
};
152152

153153
function assertValidPropertyDescriptor(descriptor, property) {
154-
if (!descriptor || !property) {
154+
if (!descriptor || !property) {
155155
return;
156156
}
157157
if (!descriptor.configurable && !descriptor.writable) {
158-
throw new TypeError(`Descriptor for property ${property} is non-configurable and non-writable`);
158+
throw new TypeError(
159+
`Descriptor for property ${property} is non-configurable and non-writable`
160+
);
159161
}
160162
if ((descriptor.get || descriptor.set) && !descriptor.configurable) {
161-
throw new TypeError(`Descriptor for accessor property ${property} is non-configurable`);
163+
throw new TypeError(
164+
`Descriptor for accessor property ${property} is non-configurable`
165+
);
162166
}
163167
if (isDataDescriptor(descriptor) && !descriptor.writable) {
164-
throw new TypeError(`Descriptor for data property ${property} is non-writable`);
168+
throw new TypeError(
169+
`Descriptor for data property ${property} is non-writable`
170+
);
165171
}
166172
}
167173

168174
function isDataDescriptor(descriptor) {
169-
return !descriptor.value && !descriptor.writable && !descriptor.set && !descriptor.get;
175+
return (
176+
!descriptor.value &&
177+
!descriptor.writable &&
178+
!descriptor.set &&
179+
!descriptor.get
180+
);
170181
}
171182

172183
/*eslint-disable no-use-before-define*/

‎test/shared-spy-stub-everything-tests.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -154,48 +154,48 @@ module.exports = function shared(createSpyOrStub) {
154154

155155
it("throws on data property descriptors that are not writable or configurable", function () {
156156
var myObj = {};
157-
Object.defineProperty(myObj, 'ignoreme', {
157+
Object.defineProperty(myObj, "ignoreme", {
158158
writable: false,
159-
configurable: false
159+
configurable: false,
160160
});
161161

162162
assert.exception(function () {
163-
createSpyOrStub(myObj, "ignoreme");
164-
},
165-
new TypeError('Descriptor for property ignoreme is non-configurable and non-writable')
166-
);
163+
createSpyOrStub(myObj, "ignoreme");
164+
}, new TypeError(
165+
"Descriptor for property ignoreme is non-configurable and non-writable"
166+
));
167167
});
168168

169169
it("throws on accessor property descriptors that are not configurable", function () {
170170
var myObj = {};
171-
Object.defineProperty(myObj, 'ignoreme', {
172-
get: function(key) {
171+
Object.defineProperty(myObj, "ignoreme", {
172+
get: function (key) {
173173
return this[key];
174174
},
175-
set: function(key, val) {
175+
set: function (key, val) {
176176
this[key] = val;
177177
},
178-
configurable: false
178+
configurable: false,
179179
});
180180

181181
assert.exception(function () {
182-
createSpyOrStub(myObj, "ignoreme");
183-
},
184-
new TypeError('Descriptor for accessor property ignoreme is non-configurable')
185-
);
182+
createSpyOrStub(myObj, "ignoreme");
183+
}, new TypeError(
184+
"Descriptor for accessor property ignoreme is non-configurable"
185+
));
186186
});
187187

188188
it("throws on data descriptors that are not stubbable", function () {
189189
var myObj = {};
190-
Object.defineProperty(myObj, 'ignoreme', {
190+
Object.defineProperty(myObj, "ignoreme", {
191191
writable: false,
192-
configurable: false
192+
configurable: false,
193193
});
194194

195195
assert.exception(function () {
196-
createSpyOrStub(myObj, "ignoreme");
197-
},
198-
new TypeError('Descriptor for data property ignoreme is non-writable')
199-
);
196+
createSpyOrStub(myObj, "ignoreme");
197+
}, new TypeError(
198+
"Descriptor for data property ignoreme is non-writable"
199+
));
200200
});
201201
};

0 commit comments

Comments
 (0)
Please sign in to comment.