diff --git a/lib/sinon/assert.js b/lib/sinon/assert.js index 5b7e02a7b..f7e0e35c1 100644 --- a/lib/sinon/assert.js +++ b/lib/sinon/assert.js @@ -107,7 +107,9 @@ assert = { throw error; }, - pass: function pass() {}, + pass: function pass() { + return; + }, callOrder: function assertCallOrder() { verifyIsStub.apply(null, arguments); diff --git a/lib/sinon/spy.js b/lib/sinon/spy.js index 2392f51db..de65b1b7d 100644 --- a/lib/sinon/spy.js +++ b/lib/sinon/spy.js @@ -38,7 +38,9 @@ function spy(object, property, types) { } if (!object && !property) { - return spy.create(function () {}); + return spy.create(function () { + return; + }); } if (!types) { @@ -150,7 +152,9 @@ var spyApi = { var name; if (typeof func !== "function") { - func = function () { }; + func = function () { + return; + }; } else { name = functionName(func); } diff --git a/test/assert-test.js b/test/assert-test.js index 5a3dae6d1..38dc0ff1b 100644 --- a/test/assert-test.js +++ b/test/assert-test.js @@ -38,8 +38,8 @@ describe("assert", function () { }); it("supports proxy property", function () { - var api = { method: function () {} }; - api.method.proxy = function () {}; + var api = { method: function () { return; } }; + api.method.proxy = function () { return; }; sinonSpy(api, "method"); api.method(); @@ -114,7 +114,7 @@ describe("assert", function () { it("fails when method is not stub", function () { assert.exception(function () { - sinonAssert.called(function () {}); + sinonAssert.called(function () { return; }); }); assert(sinonAssert.fail.called); @@ -176,7 +176,7 @@ describe("assert", function () { it("fails when method is not stub", function () { assert.exception(function () { - sinonAssert.notCalled(function () {}); + sinonAssert.notCalled(function () { return; }); }); assert(sinonAssert.fail.called); @@ -234,7 +234,7 @@ describe("assert", function () { it("fails when method is not stub", function () { assert.exception(function () { - sinonAssert.calledOnce(function () {}); + sinonAssert.calledOnce(function () { return; }); }); assert(sinonAssert.fail.called); @@ -502,7 +502,7 @@ describe("assert", function () { sinonStub(this.stub, "calledOn"); assert.exception(function () { - sinonAssert.calledOn(function () {}, object); + sinonAssert.calledOn(function () { return; }, object); }); assert.isFalse(this.stub.calledOn.calledWith(object)); @@ -583,7 +583,7 @@ describe("assert", function () { sinonStub(this.stub, "calledWithNew"); assert.exception(function () { - sinonAssert.calledWithNew(function () {}); + sinonAssert.calledWithNew(function () { return; }); }); assert.isFalse(this.stub.calledWithNew.called); @@ -659,7 +659,7 @@ describe("assert", function () { sinonStub(this.stub, "alwaysCalledWithNew"); assert.exception(function () { - sinonAssert.alwaysCalledWithNew(function () {}); + sinonAssert.alwaysCalledWithNew(function () { return; }); }); assert.isFalse(this.stub.alwaysCalledWithNew.called); @@ -952,7 +952,7 @@ describe("assert", function () { it("fails if method is not fake", function () { assert.exception(function () { - sinonAssert.alwaysCalledOn(function () {}, {}); + sinonAssert.alwaysCalledOn(function () { return; }, {}); }); }); @@ -1005,7 +1005,7 @@ describe("assert", function () { it("fails if method is not fake", function () { assert.exception(function () { - sinonAssert.alwaysCalledWith(function () {}); + sinonAssert.alwaysCalledWith(function () { return; }); }); }); @@ -1163,7 +1163,7 @@ describe("assert", function () { describe("message", function () { beforeEach(function () { this.obj = { - doSomething: function () {} + doSomething: function () { return; } }; sinonSpy(this.obj, "doSomething"); @@ -1217,7 +1217,7 @@ describe("assert", function () { }); it("assert.callOrder exception message", function () { - var obj = { doop: function () {}, foo: function () {} }; + var obj = { doop: function () { return; }, foo: function () { return; } }; sinonSpy(obj, "doop"); sinonSpy(obj, "foo"); @@ -1233,7 +1233,7 @@ describe("assert", function () { }); it("assert.callOrder with missing first call exception message", function () { - var obj = { doop: function () {}, foo: function () {} }; + var obj = { doop: function () { return; }, foo: function () { return; } }; sinonSpy(obj, "doop"); sinonSpy(obj, "foo"); @@ -1247,7 +1247,7 @@ describe("assert", function () { }); it("assert.callOrder with missing last call exception message", function () { - var obj = { doop: function () {}, foo: function () {} }; + var obj = { doop: function () { return; }, foo: function () { return; } }; sinonSpy(obj, "doop"); sinonSpy(obj, "foo"); @@ -1505,7 +1505,7 @@ describe("assert", function () { it("assert.calledWith match.instanceOf exception message", function () { this.obj.doSomething(); - var matcher = sinonMatch.instanceOf(function CustomType() {}); + var matcher = sinonMatch.instanceOf(function CustomType() { return; }); assert.equals( this.message("calledWith", this.obj.doSomething, matcher).replace(/ at.*/g, ""), @@ -1553,7 +1553,7 @@ describe("assert", function () { it("assert.calledWith match test function exception message", function () { this.obj.doSomething(); - var matcher = sinonMatch({ test: function custom() {} }); + var matcher = sinonMatch({ test: function custom() { return; } }); assert.equals( this.message("calledWith", this.obj.doSomething, matcher).replace(/ at.*/g, ""), @@ -1673,7 +1673,7 @@ describe("assert", function () { var obj = {}; function setupSymbol(symbol) { - obj[symbol] = function () {}; + obj[symbol] = function () { return; }; sinonSpy(obj, symbol); } diff --git a/test/call-test.js b/test/call-test.js index 29c5990ea..cd6a32bab 100644 --- a/test/call-test.js +++ b/test/call-test.js @@ -11,8 +11,8 @@ var refute = referee.refute; function spyCallSetUp() { this.thisValue = {}; this.args = [{}, [], new Error(), 3]; - this.returnValue = function () {}; - this.call = sinonSpyCall(function () {}, this.thisValue, + this.returnValue = function () { return; }; + this.call = sinonSpyCall(function () { return; }, this.thisValue, this.args, this.returnValue, null, 0); } @@ -121,14 +121,14 @@ describe("sinonSpy.call", function () { }); it("stores given call id", function () { - var call = sinonSpyCall(function () {}, {}, [], null, null, 42); + var call = sinonSpyCall(function () { return; }, {}, [], null, null, 42); assert.same(call.callId, 42); }); it("throws if callId is undefined", function () { assert.exception(function () { - sinonSpyCall.create(function () {}, {}, []); + sinonSpyCall.create(function () { return; }, {}, []); }); }); @@ -219,13 +219,13 @@ describe("sinonSpy.call", function () { }); it("returns true for no arguments", function () { - var call = sinonSpyCall(function () {}, {}, [], null, null, 0); + var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0); assert(call.calledWithExactly()); }); it("returns false when called with no args but matching one", function () { - var call = sinonSpyCall(function () {}, {}, [], null, null, 0); + var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0); assert.isFalse(call.calledWithExactly({})); }); @@ -463,8 +463,8 @@ describe("sinonSpy.call", function () { describe(".callback", function () { it("it should be a reference for the callback", function () { var spy = sinonSpy(); - var callback1 = function () {}; - var callback2 = function () {}; + var callback1 = function () { return; }; + var callback2 = function () { return; }; spy(1, 2, 3, callback1); assert.equals(spy.getCall(0).callback, callback1); @@ -594,7 +594,7 @@ describe("sinonSpy.call", function () { describe("call.invokeCallback", function () { it("is alias for yield", function () { - var call = sinonSpyCall(function () {}, {}, [], null, null, 0); + var call = sinonSpyCall(function () { return; }, {}, [], null, null, 0); assert.same(call.yield, call.invokeCallback); }); @@ -1040,7 +1040,7 @@ describe("sinonSpy.call", function () { describe("constructor", function () { beforeEach(function () { - this.CustomConstructor = function () {}; + this.CustomConstructor = function () { return; }; this.customPrototype = this.CustomConstructor.prototype; sinonSpy(this, "CustomConstructor"); }); @@ -1082,7 +1082,7 @@ describe("sinonSpy.call", function () { }); it("haves toString method", function () { - var obj = { meth: function () {} }; + var obj = { meth: function () { return; } }; sinonSpy(obj, "meth"); assert.equals(obj.meth.toString(), "meth"); @@ -1095,14 +1095,14 @@ describe("sinonSpy.call", function () { }); it("toString should report name of spied function", function () { - function myTestFunc() {} + function myTestFunc() { return; } var spy = sinonSpy(myTestFunc); assert.equals(spy.toString(), "myTestFunc"); }); it("toString should prefer displayName property if available", function () { - function myTestFunc() {} + function myTestFunc() { return; } myTestFunc.displayName = "My custom method"; var spy = sinonSpy(myTestFunc); @@ -1389,11 +1389,11 @@ describe("sinonSpy.call", function () { describe(".printf", function () { describe("name", function () { it("named", function () { - var named = sinonSpy(function cool() { }); + var named = sinonSpy(function cool() { return; }); assert.equals(named.printf("%n"), "cool"); }); it("anon", function () { - var anon = sinonSpy(function () {}); + var anon = sinonSpy(function () { return; }); assert.equals(anon.printf("%n"), "spy"); var noFn = sinonSpy(); diff --git a/test/fake-test.js b/test/fake-test.js index 850ef48c1..f0cc2d2c2 100644 --- a/test/fake-test.js +++ b/test/fake-test.js @@ -29,7 +29,7 @@ function verifyProxy(func, argument) { }); } -function noop() {} +function noop() { return; } function requirePromiseSupport() { if (typeof Promise !== "function") { @@ -50,7 +50,7 @@ describe("fake", function () { }); describe("when passed a Function", function () { - verifyProxy(fake, function () {}); + verifyProxy(fake, function () { return; }); it("should keep the `this` context of the wrapped function", function () { function method() { return this.foo; } @@ -81,8 +81,8 @@ describe("fake", function () { describe(".callback", function () { it("it should be a reference for the callback in the last call", function () { var f = fake(); - var callback1 = function () {}; - var callback2 = function () {}; + var callback1 = function () { return; }; + var callback2 = function () { return; }; f(1, 2, 3, callback1); assert.equals(f.callback, callback1); @@ -264,7 +264,7 @@ describe("fake", function () { var callback = sinon.spy(); var myFake = fake.yields(); - myFake(function () {}, callback); + myFake(function () { return; }, callback); sinon.assert.calledOnce(callback); }); @@ -273,7 +273,7 @@ describe("fake", function () { var myFake = fake.yields(); assert.exception(function () { - myFake(function () {}, "not a function"); + myFake(function () { return; }, "not a function"); }, /TypeError: Expected last argument to be a function/); }); }); @@ -301,7 +301,7 @@ describe("fake", function () { var callback = sinon.spy(); var myFake = fake.yieldsAsync(); - myFake(function () {}, callback); + myFake(function () { return; }, callback); sinon.assert.notCalled(callback); @@ -316,7 +316,7 @@ describe("fake", function () { var myFake = fake.yieldsAsync(); assert.exception(function () { - myFake(function () {}, "not a function"); + myFake(function () { return; }, "not a function"); }, /TypeError: Expected last argument to be a function/); }); }); diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index 3b5854510..d0b755320 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -75,8 +75,8 @@ describe("issues", function () { describe("#852 - createStubInstance on intherited constructors", function () { it("must not throw error", function () { - var A = function () {}; - var B = function () {}; + var A = function () { return; }; + var B = function () { return; }; B.prototype = Object.create(A.prototype); B.prototype.constructor = A; @@ -89,7 +89,7 @@ describe("issues", function () { describe("#852(2) - createStubInstance should on same constructor", function () { it("must be idempotent", function () { - var A = function () {}; + var A = function () { return; }; refute.exception(function () { sinon.createStubInstance(A); sinon.createStubInstance(A); @@ -98,7 +98,7 @@ describe("issues", function () { }); describe("#950 - first execution of a spy as a method renames that spy", function () { - function bob() {} + function bob() { return; } // IE 11 does not support the function name property if (bob.name) { @@ -144,11 +144,11 @@ describe("issues", function () { oldWatch = Object.prototype.watch; if (typeof Object.prototype.watch !== "function") { - Object.prototype.watch = function rolex() {}; // eslint-disable-line no-extend-native + Object.prototype.watch = function rolex() { return; }; // eslint-disable-line no-extend-native } var stubbedObject = sinon.stub({ - watch: function () {} + watch: function () { return; } }); stubbedObject.watch(); @@ -337,7 +337,7 @@ describe("issues", function () { }); it("can stub methods on the prototype", function () { - var proto = { someFunction: function () {} }; + var proto = { someFunction: function () { return; } }; var instance = Object.create(proto); var stub = sandbox.stub(instance, "someFunction"); @@ -383,7 +383,7 @@ describe("issues", function () { describe("#1442 - callThrough with a mock expectation", function () { it("should call original method", function () { var foo = { - bar: function () { } + bar: function () { return; } }; var mock = this.sandbox.mock(foo); @@ -398,7 +398,7 @@ describe("issues", function () { describe("#1648 - resetHistory ", function () { it("should reset property spies", function () { var obj = { - func: function () {}, + func: function () { return; }, get prop() { return 1; } @@ -538,8 +538,8 @@ describe("issues", function () { describe("#1882", function () { it("should use constructor name when checking deepEquality", function () { - function ClassWithoutProps() {} - function AnotherClassWithoutProps() {} + function ClassWithoutProps() { return; } + function AnotherClassWithoutProps() { return; } ClassWithoutProps.prototype.constructor = ClassWithoutProps; AnotherClassWithoutProps.prototype.constructor = AnotherClassWithoutProps; var arg1 = new ClassWithoutProps(); //arg1.constructor.name === ClassWithoutProps diff --git a/test/match-test.js b/test/match-test.js index 8488833f0..295b613a2 100644 --- a/test/match-test.js +++ b/test/match-test.js @@ -69,7 +69,7 @@ function propertyMatcherTests(matcher, additionalTests) { it("compares with matcher", function () { var has = matcher("callback", sinonMatch.typeOf("function")); - assert(has.test({ callback: function () {} })); + assert(has.test({ callback: function () { return; } })); }); if (typeof additionalTests === "function") { @@ -80,13 +80,13 @@ function propertyMatcherTests(matcher, additionalTests) { describe("sinonMatch", function () { it("returns matcher", function () { - var match = sinonMatch(function () {}); + var match = sinonMatch(function () { return; }); assert(sinonMatch.isMatcher(match)); }); it("exposes test function", function () { - var test = function () {}; + var test = function () { return; }; var match = sinonMatch(test); @@ -300,7 +300,7 @@ describe("sinonMatch", function () { }); it("returns false if test function in object returns nothing", function () { - var match = sinonMatch({ test: function () {}}); + var match = sinonMatch({ test: function () { return; }}); assert.isFalse(match.test()); }); @@ -323,13 +323,13 @@ describe("sinonMatch", function () { it("returns message", function () { var message = "hello sinonMatch"; - var match = sinonMatch(function () {}, message); + var match = sinonMatch(function () { return; }, message); assert.same(match.toString(), message); }); it("defaults to match(functionName)", function () { - var match = sinonMatch(function custom() {}); + var match = sinonMatch(function custom() { return; }); assert.same(match.toString(), "match(custom)"); }); @@ -368,7 +368,7 @@ describe("sinonMatch", function () { it("returns true if test is called with any object", function () { assert(sinonMatch.defined.test({})); - assert(sinonMatch.defined.test(function () {})); + assert(sinonMatch.defined.test(function () { return; })); }); }); @@ -459,7 +459,7 @@ describe("sinonMatch", function () { [1, 2, 3], ["a", "b", "c"], [{ a: "a" }, { b: "b"}], - [function () {}, function () {}], + [function () { return; }, function () { return; }], [null, undefined] ]; @@ -542,13 +542,13 @@ describe("sinonMatch", function () { if (typeof Symbol !== "undefined" && typeof Symbol.hasInstance !== "undefined") { it("does not throw if given argument defines Symbol.hasInstance", function () { var objectWithCustomTypeChecks = {}; - objectWithCustomTypeChecks[Symbol.hasInstance] = function () {}; + objectWithCustomTypeChecks[Symbol.hasInstance] = function () { return; }; sinonMatch.instanceOf(objectWithCustomTypeChecks); }); } it("returns matcher", function () { - var instanceOf = sinonMatch.instanceOf(function () {}); + var instanceOf = sinonMatch.instanceOf(function () { return; }); assert(sinonMatch.isMatcher(instanceOf)); }); @@ -688,7 +688,7 @@ describe("sinonMatch", function () { refute(every.test(1)); refute(every.test("a")); refute(every.test(null)); - refute(every.test(function () {})); + refute(every.test(function () { return; })); }); it("matches an object if the predicate is true for every property", function () { @@ -767,7 +767,7 @@ describe("sinonMatch", function () { refute(some.test(1)); refute(some.test("a")); refute(some.test(null)); - refute(some.test(function () {})); + refute(some.test(function () { return; })); }); it("matches an object if the predicate is true for some of the properties", function () { diff --git a/test/mock-test.js b/test/mock-test.js index 7d93ecabf..8eeb55a3f 100644 --- a/test/mock-test.js +++ b/test/mock-test.js @@ -36,7 +36,7 @@ describe("sinonMock", function () { describe(".expects", function () { beforeEach(function () { - this.mock = sinonMock.create({ someMethod: function () {} }); + this.mock = sinonMock.create({ someMethod: function () { return; } }); }); it("throws without method", function () { @@ -324,7 +324,7 @@ describe("sinonMock", function () { }); it("should not throw when exceeding at least expectation", function () { - var obj = { foobar: function () {} }; + var obj = { foobar: function () { return; } }; var mock = sinonMock(obj); mock.expects("foobar").atLeast(1); @@ -337,7 +337,7 @@ describe("sinonMock", function () { }); it("should not throw when exceeding at least expectation and withargs", function () { - var obj = { foobar: function () {} }; + var obj = { foobar: function () { return; } }; var mock = sinonMock(obj); mock.expects("foobar").withArgs("arg1"); @@ -558,7 +558,7 @@ describe("sinonMock", function () { it("works with sinon matchers", function () { this.expectation.withArgs(sinonMatch.number, sinonMatch.string, sinonMatch.func); - this.expectation(1, "test", function () {}); + this.expectation(1, "test", function () { return; }); assert(this.expectation.met()); }); @@ -710,7 +710,7 @@ describe("sinonMock", function () { describe(".verify", function () { beforeEach(function () { - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; this.mock = sinonMock.create(this.object); }); @@ -947,7 +947,7 @@ describe("sinonMock", function () { describe(".usingPromise", function () { beforeEach(function () { - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; this.mock = sinonMock.create(this.object); }); @@ -986,7 +986,7 @@ describe("sinonMock", function () { describe("mock object", function () { beforeEach(function () { - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; this.mock = sinonMock.create(this.object); }); @@ -1042,7 +1042,7 @@ describe("sinonMock", function () { describe("mock method multiple times", function () { beforeEach(function () { this.thisValue = {}; - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; this.mock = sinonMock.create(this.object); this.mock.expects("method"); @@ -1077,7 +1077,7 @@ describe("sinonMock", function () { }); it("allows mock calls in any order", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; var mock = sinonMock(object); mock.expects("method").once().withArgs(42); mock.expects("method").twice().withArgs("Yeah"); diff --git a/test/sandbox-test.js b/test/sandbox-test.js index b5c4399d8..3ba146880 100644 --- a/test/sandbox-test.js +++ b/test/sandbox-test.js @@ -36,7 +36,7 @@ referee.add("fakeServerWithClock", { }); describe("Sandbox", function () { - function noop() {} + function noop() { return; } it("exposes match", function () { var sandbox = new Sandbox(); @@ -71,7 +71,7 @@ describe("Sandbox", function () { }); it("returns a mock", function () { - var object = { method: function () { }}; + var object = { method: function () { return; }}; var actual = this.sandbox.mock(object); actual.expects("method"); @@ -82,7 +82,7 @@ describe("Sandbox", function () { it("adds mock to fake array", function () { var fakes = this.sandbox.getFakes(); - var object = { method: function () { }}; + var object = { method: function () { return; }}; var expected = this.sandbox.mock(object); assert(fakes.indexOf(expected) !== -1); @@ -106,8 +106,8 @@ describe("Sandbox", function () { it("appends mocks and stubs to fake array", function () { var fakes = this.sandbox.getFakes(); - this.sandbox.mock({ method: function () {} }, "method"); - this.sandbox.stub({ method: function () {} }, "method"); + this.sandbox.mock({ method: function () { return; } }, "method"); + this.sandbox.stub({ method: function () { return; } }, "method"); assert.equals(fakes.length, 2); }); @@ -139,8 +139,8 @@ describe("Sandbox", function () { }); it("stubs existing methods", function () { - var Class = function () {}; - Class.prototype.method = function () {}; + var Class = function () { return; }; + Class.prototype.method = function () { return; }; var stub = this.sandbox.createStubInstance(Class); stub.method.returns(3); @@ -162,10 +162,10 @@ describe("Sandbox", function () { }); it("resets all stub methods on reset()", function () { - var Class = function () {}; - Class.prototype.method1 = function () {}; - Class.prototype.method2 = function () {}; - Class.prototype.method3 = function () {}; + var Class = function () { return; }; + Class.prototype.method1 = function () { return; }; + Class.prototype.method2 = function () { return; }; + Class.prototype.method3 = function () { return; }; var stub = this.sandbox.createStubInstance(Class); stub.method1.returns(1); @@ -181,7 +181,7 @@ describe("Sandbox", function () { }); it("doesn't stub fake methods", function () { - var Class = function () {}; + var Class = function () { return; }; var stub = this.sandbox.createStubInstance(Class); assert.exception(function () { @@ -194,7 +194,7 @@ describe("Sandbox", function () { var c = a + b; throw c; }; - Class.prototype.method = function () {}; + Class.prototype.method = function () { return; }; var stub = this.sandbox.createStubInstance(Class); refute.exception(function () { @@ -204,7 +204,7 @@ describe("Sandbox", function () { it("retains non function values", function () { var TYPE = "some-value"; - var Class = function () {}; + var Class = function () { return; }; Class.prototype.type = TYPE; var stub = this.sandbox.createStubInstance(Class); @@ -217,7 +217,7 @@ describe("Sandbox", function () { throw "error"; } }; - var Class = function () {}; + var Class = function () { return; }; Class.prototype = proto; var stub = this.sandbox.createStubInstance(Class); @@ -272,7 +272,7 @@ describe("Sandbox", function () { }); it("creates a stub", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; this.sandbox.stub(object, "method"); @@ -281,7 +281,7 @@ describe("Sandbox", function () { it("adds stub to fake array", function () { var fakes = this.sandbox.getFakes(); - var object = { method: function () {} }; + var object = { method: function () { return; } }; var stub = this.sandbox.stub(object, "method"); assert.isTrue(fakes.indexOf(stub) !== -1); @@ -290,8 +290,8 @@ describe("Sandbox", function () { it("appends stubs to fake array", function () { var fakes = this.sandbox.getFakes(); - this.sandbox.stub({ method: function () {} }, "method"); - this.sandbox.stub({ method: function () {} }, "method"); + this.sandbox.stub({ method: function () { return; } }, "method"); + this.sandbox.stub({ method: function () { return; } }, "method"); assert.equals(fakes.length, 2); }); @@ -299,9 +299,9 @@ describe("Sandbox", function () { it("adds all object methods to fake array", function () { var fakes = this.sandbox.getFakes(); var object = { - method: function () {}, - method2: function () {}, - method3: function () {} + method: function () { return; }, + method2: function () { return; }, + method3: function () { return; } }; Object.defineProperty(object, "method3", { @@ -317,12 +317,12 @@ describe("Sandbox", function () { }); it("returns a stubbed object", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; assert.equals(this.sandbox.stub(object), object); }); it("returns a stubbed method", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; assert.equals(this.sandbox.stub(object, "method"), object.method); }); @@ -334,7 +334,7 @@ describe("Sandbox", function () { it("stubs environment property", function () { var originalPrintWarning = deprecated.printWarning; - deprecated.printWarning = function () {}; + deprecated.printWarning = function () { return; }; this.sandbox.stub(process.env, "HELL").value("froze over"); assert.equals(process.env.HELL, "froze over"); @@ -353,7 +353,7 @@ describe("Sandbox", function () { it("stubs number property", function () { var originalPrintWarning = deprecated.printWarning; - deprecated.printWarning = function () {}; + deprecated.printWarning = function () { return; }; this.sandbox.stub(this.object, "property").value(1); @@ -364,7 +364,7 @@ describe("Sandbox", function () { it("restores number property", function () { var originalPrintWarning = deprecated.printWarning; - deprecated.printWarning = function () {}; + deprecated.printWarning = function () { return; }; this.sandbox.stub(this.object, "property").value(1); this.sandbox.restore(); @@ -376,7 +376,7 @@ describe("Sandbox", function () { it("fails if property does not exist", function () { var originalPrintWarning = deprecated.printWarning; - deprecated.printWarning = function () {}; + deprecated.printWarning = function () { return; }; var sandbox = this.sandbox; var object = {}; @@ -394,7 +394,7 @@ describe("Sandbox", function () { var object = {}; var originalPrintWarning = deprecated.printWarning; - deprecated.printWarning = function () {}; + deprecated.printWarning = function () { return; }; assert.exception(function () { sandbox.stub(object, Symbol()); @@ -589,8 +589,8 @@ describe("Sandbox", function () { }); it("should replace a function property", function () { - var replacement = function replacement() {}; - var existing = function existing() {}; + var replacement = function replacement() { return; }; + var existing = function existing() { return; }; var object = { property: existing }; @@ -833,7 +833,7 @@ describe("Sandbox", function () { it("should error when descriptor has no getter", function () { var sandbox = this.sandbox; var object = { // eslint-disable-line accessor-pairs - set catpants(_) {} + set catpants(_) { return; } }; assert.exception( @@ -1028,7 +1028,7 @@ describe("Sandbox", function () { var sandbox = this.sandbox; // eslint-disable-next-line accessor-pairs var object = { - set foo(value) {} + set foo(value) { return; } }; sandbox.replaceSetter(object, "foo", sinonFake()); @@ -1309,7 +1309,7 @@ describe("Sandbox", function () { }); it("calls sinon.useFakeXMLHttpRequest", function () { - var stubXhr = { restore: function () {} }; + var stubXhr = { restore: function () { return; } }; this.sandbox.stub(fakeXhr, "useFakeXMLHttpRequest").returns(stubXhr); var returnedXhr = this.sandbox.useFakeXMLHttpRequest(); @@ -1319,14 +1319,14 @@ describe("Sandbox", function () { }); it("returns fake xhr object created by nise", function () { - this.sandbox.stub(fakeXhr, "useFakeXMLHttpRequest").returns({ restore: function () {} }); + this.sandbox.stub(fakeXhr, "useFakeXMLHttpRequest").returns({ restore: function () { return; } }); this.sandbox.useFakeXMLHttpRequest(); assert(fakeXhr.useFakeXMLHttpRequest.called); }); it("doesn't secretly use useFakeServer", function () { - this.sandbox.stub(fakeServer, "create").returns({ restore: function () {} }); + this.sandbox.stub(fakeServer, "create").returns({ restore: function () { return; } }); this.sandbox.useFakeXMLHttpRequest(); assert(fakeServer.create.notCalled); @@ -1561,7 +1561,7 @@ describe("Sandbox", function () { }); it("does not inject properties if they are already present", function () { - var server = function () {}; + var server = function () { return; }; var clock = {}; var spy = false; var object = { server: server, clock: clock, spy: spy}; diff --git a/test/spy-test.js b/test/spy-test.js index b94d76158..e6ff962ea 100644 --- a/test/spy-test.js +++ b/test/spy-test.js @@ -223,7 +223,7 @@ describe("spy", function () { }); it("returns spy function", function () { - var func = function () {}; + var func = function () { return; }; var spy = createSpy.create(func); assert.isFunction(spy); @@ -231,7 +231,7 @@ describe("spy", function () { }); it("mirrors custom properties on function", function () { - var func = function () {}; + var func = function () { return; }; func.myProp = 42; var spy = createSpy.create(func); @@ -245,7 +245,7 @@ describe("spy", function () { }); it("does not overwrite original create property", function () { - var func = function () {}; + var func = function () { return; }; var object = func.create = {}; var spy = createSpy.create(func); @@ -380,8 +380,8 @@ describe("spy", function () { } var object = { - f1: function () {}, - f2: function () {} + f1: function () { return; }, + f2: function () { return; } }; // f1: the order of withArgs(1), withArgs(1, 1) @@ -440,7 +440,7 @@ describe("spy", function () { }); it("passes 'new' to underlying function", function () { - function TestClass() {} + function TestClass() { return; } var SpyClass = createSpy.create(TestClass); @@ -500,37 +500,39 @@ describe("spy", function () { }); it("retains function length 0", function () { - var spy = createSpy.create(function () {}); + var spy = createSpy.create(function () { return; }); assert.equals(spy.length, 0); }); it("retains function length 1", function () { - var spy = createSpy.create(function (a) {}); // eslint-disable-line no-unused-vars + var spy = createSpy.create(function (a) { return; }); // eslint-disable-line no-unused-vars assert.equals(spy.length, 1); }); it("retains function length 2", function () { - var spy = createSpy.create(function (a, b) {}); // eslint-disable-line no-unused-vars + var spy = createSpy.create(function (a, b) { return; }); // eslint-disable-line no-unused-vars assert.equals(spy.length, 2); }); it("retains function length 3", function () { - var spy = createSpy.create(function (a, b, c) {}); // eslint-disable-line no-unused-vars + var spy = createSpy.create(function (a, b, c) { return; }); // eslint-disable-line no-unused-vars assert.equals(spy.length, 3); }); it("retains function length 4", function () { - var spy = createSpy.create(function (a, b, c, d) {}); // eslint-disable-line no-unused-vars + var spy = createSpy.create(function (a, b, c, d) { return; }); // eslint-disable-line no-unused-vars assert.equals(spy.length, 4); }); it("retains function length 12", function () { - var func12Args = function (a, b, c, d, e, f, g, h, i, j, k, l) {}; // eslint-disable-line no-unused-vars + var func12Args = function (a, b, c, d, e, f, g, h, i, j, k, l) { // eslint-disable-line no-unused-vars + return; + }; var spy = createSpy.create(func12Args); assert.equals(spy.length, 12); @@ -828,7 +830,7 @@ describe("spy", function () { }); it("is true if called with new on custom constructor", function () { - function MyThing() {} + function MyThing() { return; } MyThing.prototype = {}; var ns = { MyThing: MyThing }; createSpy(ns, "MyThing"); @@ -935,7 +937,7 @@ describe("spy", function () { }); it("stacks up objects", function () { - function MyConstructor() {} + function MyConstructor() { return; } var objects = [{}, [], new MyConstructor(), { id: 243 }]; this.spy(); this.spy.call(objects[0]); @@ -1530,7 +1532,7 @@ describe("spy", function () { }); it("returns true when returned value once", function () { - var values = [{}, 2, "hey", function () {}]; + var values = [{}, 2, "hey", function () { return; }]; var spy = createSpy.create(function () { return values[spy.callCount]; }); @@ -1544,7 +1546,7 @@ describe("spy", function () { }); it("returns false when value is never returned", function () { - var values = [{}, 2, "hey", function () {}]; + var values = [{}, 2, "hey", function () { return; }]; var spy = createSpy.create(function () { return values[spy.callCount]; }); @@ -1627,7 +1629,7 @@ describe("spy", function () { }); it("contains the created object for spied constructors", function () { - var Spy = createSpy.create(function () { }); + var Spy = createSpy.create(function () { return; }); var result = new Spy(); @@ -2126,7 +2128,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); assert.exception( @@ -2225,7 +2227,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); var thisObj = { name1: "value1", name2: "value2" }; @@ -2332,7 +2334,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); assert.exception( @@ -2420,7 +2422,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); var thisObj = { name1: "value1", name2: "value2" }; @@ -2501,7 +2503,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); assert.exception( @@ -2596,7 +2598,7 @@ describe("spy", function () { }); it("includes spy name in error message", function () { - var api = { someMethod: function () {} }; + var api = { someMethod: function () { return; } }; var spy = createSpy(api, "someMethod"); var thisObj = { name1: "value1", name2: "value2" }; @@ -2738,7 +2740,7 @@ describe("spy", function () { }); it("matches the function length", function () { - var api = { someMethod: function (a, b, c) {} }; // eslint-disable-line no-unused-vars + var api = { someMethod: function (a, b, c) { return; } }; // eslint-disable-line no-unused-vars var spy = createSpy(api, "someMethod"); assert.equals(spy.length, 3); diff --git a/test/stub-test.js b/test/stub-test.js index 0fcea0333..2cc188fa8 100644 --- a/test/stub-test.js +++ b/test/stub-test.js @@ -1120,7 +1120,7 @@ describe("stub", function () { describe(".objectMethod", function () { beforeEach(function () { - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; }); @@ -1181,7 +1181,7 @@ describe("stub", function () { }); it("successfully stubs falsey properties", function () { - var obj = { 0: function () { } }; + var obj = { 0: function () { return; } }; createStub(obj, 0).callsFake(function () { return "stubbed value"; @@ -1192,7 +1192,7 @@ describe("stub", function () { it("does not stub function object", function () { assert.exception(function () { - createStub(function () {}); + createStub(function () { return; }); }); }); }); @@ -1200,9 +1200,9 @@ describe("stub", function () { describe("everything", function () { it("stubs all methods of object without property", function () { var obj = { - func1: function () {}, - func2: function () {}, - func3: function () {} + func1: function () { return; }, + func2: function () { return; }, + func3: function () { return; } }; createStub(obj); @@ -1213,8 +1213,8 @@ describe("stub", function () { }); it("stubs prototype methods", function () { - function Obj() {} - Obj.prototype.func1 = function () {}; + function Obj() { return; } + Obj.prototype.func1 = function () { return; }; var obj = new Obj(); createStub(obj); @@ -1237,12 +1237,12 @@ describe("stub", function () { it("handles non-enumerable properties", function () { var obj = { - func1: function () {}, - func2: function () {} + func1: function () { return; }, + func2: function () { return; } }; Object.defineProperty(obj, "func3", { - value: function () {}, + value: function () { return; }, writable: true, configurable: true }); @@ -1255,9 +1255,9 @@ describe("stub", function () { }); it("handles non-enumerable properties on prototypes", function () { - function Obj() {} + function Obj() { return; } Object.defineProperty(Obj.prototype, "func1", { - value: function () {}, + value: function () { return; }, writable: true, configurable: true }); @@ -1281,10 +1281,10 @@ describe("stub", function () { it("does not fail on overrides", function () { var parent = { - func: function () {} + func: function () { return; } }; var child = Object.create(parent); - child.func = function () {}; + child.func = function () { return; }; refute.exception(function () { createStub(child); @@ -1320,7 +1320,7 @@ describe("stub", function () { describe("stubbed function", function () { it("has toString method", function () { - var obj = { meth: function () {} }; + var obj = { meth: function () { return; } }; createStub(obj, "meth"); assert.equals(obj.meth.toString(), "meth"); @@ -1360,7 +1360,7 @@ describe("stub", function () { }); it("includes stub name and actual arguments in error", function () { - var myObj = { somethingAwesome: function () {} }; + var myObj = { somethingAwesome: function () { return; } }; var stub = createStub(myObj, "somethingAwesome").yields(); assert.exception( @@ -1476,7 +1476,7 @@ describe("stub", function () { }); it("includes stub name and actual arguments in error", function () { - var myObj = { somethingAwesome: function () {} }; + var myObj = { somethingAwesome: function () { return; } }; var stub = createStub(myObj, "somethingAwesome").yieldsRight(); assert.exception( @@ -1605,7 +1605,7 @@ describe("stub", function () { }); it("includes stub name and actual arguments in error", function () { - var myObj = { somethingAwesome: function () {} }; + var myObj = { somethingAwesome: function () { return; } }; var stub = createStub(myObj, "somethingAwesome").yieldsOn(this.fakeContext); assert.exception( @@ -1743,7 +1743,7 @@ describe("stub", function () { }); it("includes stub name and actual arguments in error", function () { - var myObj = { somethingAwesome: function () {} }; + var myObj = { somethingAwesome: function () { return; } }; var stub = createStub(myObj, "somethingAwesome").yieldsTo("success"); assert.exception( @@ -1890,7 +1890,7 @@ describe("stub", function () { }); it("includes stub name and actual arguments in error", function () { - var myObj = { somethingAwesome: function () {} }; + var myObj = { somethingAwesome: function () { return; } }; var stub = createStub(myObj, "somethingAwesome").yieldsToOn("success", this.fakeContext); assert.exception( @@ -2493,7 +2493,7 @@ describe("stub", function () { describe(".reset", function () { it("resets behavior", function () { - var obj = { a: function () {} }; + var obj = { a: function () { return; } }; var spy = createSpy(); createStub(obj, "a").callsArg(1); @@ -2683,7 +2683,7 @@ describe("stub", function () { }); it("matches the function length", function () { - var api = { someMethod: function (a, b, c) {} }; // eslint-disable-line no-unused-vars + var api = { someMethod: function (a, b, c) { return; } }; // eslint-disable-line no-unused-vars var stub = createStub(api, "someMethod"); assert.equals(stub.length, 3); @@ -2692,8 +2692,8 @@ describe("stub", function () { describe(".createStubInstance", function () { it("stubs existing methods", function () { - var Class = function () {}; - Class.prototype.method = function () {}; + var Class = function () { return; }; + Class.prototype.method = function () { return; }; var stub = createStubInstance(Class); stub.method.returns(3); @@ -2701,7 +2701,7 @@ describe("stub", function () { }); it("doesn't stub fake methods", function () { - var Class = function () {}; + var Class = function () { return; }; var stub = createStubInstance(Class); assert.exception(function () { @@ -2714,7 +2714,7 @@ describe("stub", function () { var c = a + b; throw c; }; - Class.prototype.method = function () {}; + Class.prototype.method = function () { return; }; var stub = createStubInstance(Class); refute.exception(function () { @@ -2724,7 +2724,7 @@ describe("stub", function () { it("retains non function values", function () { var TYPE = "some-value"; - var Class = function () {}; + var Class = function () { return; }; Class.prototype.type = TYPE; var stub = createStubInstance(Class); @@ -2737,7 +2737,7 @@ describe("stub", function () { throw "error"; } }; - var Class = function () {}; + var Class = function () { return; }; Class.prototype = proto; var stub = createStubInstance(Class); @@ -2758,8 +2758,8 @@ describe("stub", function () { }); it("allows providing optional overrides", function () { - var Class = function () {}; - Class.prototype.method = function () {}; + var Class = function () { return; }; + Class.prototype.method = function () { return; }; var stub = createStubInstance(Class, { method: createStub().returns(3) @@ -2769,8 +2769,8 @@ describe("stub", function () { }); it("allows providing optional returned values", function () { - var Class = function () {}; - Class.prototype.method = function () {}; + var Class = function () { return; }; + Class.prototype.method = function () { return; }; var stub = createStubInstance(Class, { method: 3 @@ -2780,8 +2780,8 @@ describe("stub", function () { }); it("throws an exception when trying to override non-existing property", function () { - var Class = function () {}; - Class.prototype.method = function () {}; + var Class = function () { return; }; + Class.prototype.method = function () { return; }; assert.exception(function () { createStubInstance(Class, { @@ -3073,7 +3073,7 @@ describe("stub", function () { }); it("allows stubbing function static properties", function () { - var myFunc = function () {}; + var myFunc = function () { return; }; myFunc.prop = "rawString"; createStub(myFunc, "prop").value("newString"); @@ -3081,7 +3081,7 @@ describe("stub", function () { }); it("allows restoring function static properties", function () { - var myFunc = function () {}; + var myFunc = function () { return; }; myFunc.prop = "rawString"; var stub = createStub(myFunc, "prop").value("newString"); diff --git a/test/util/core/called-in-order-test.js b/test/util/core/called-in-order-test.js index a19df7918..4d99a2f84 100644 --- a/test/util/core/called-in-order-test.js +++ b/test/util/core/called-in-order-test.js @@ -5,9 +5,9 @@ var calledInOrder = require("../../../lib/sinon/util/core/called-in-order"); var sinonStub = require("../../../lib/sinon/stub"); var assert = referee.assert; -var testObject1 = {someFunction: function () {}}; -var testObject2 = {otherFunction: function () {}}; -var testObject3 = {thirdFunction: function () {}}; +var testObject1 = {someFunction: function () { return; }}; +var testObject2 = {otherFunction: function () { return; }}; +var testObject3 = {thirdFunction: function () { return; }}; function testMethod() { testObject1.someFunction(); diff --git a/test/util/core/deep-equal-test.js b/test/util/core/deep-equal-test.js index 65d16863c..7a9426a63 100644 --- a/test/util/core/deep-equal-test.js +++ b/test/util/core/deep-equal-test.js @@ -46,7 +46,7 @@ describe("util/core/deepEqual", function () { }); it("passes same function", function () { - var func = function () {}; + var func = function () { return; }; assert(deepEqual(func, func)); }); @@ -245,7 +245,7 @@ describe("util/core/deepEqual", function () { } it("passes deep objects", function () { - var func = function () {}; + var func = function () { return; }; var obj1 = { a: 1, diff --git a/test/util/core/function-to-string-test.js b/test/util/core/function-to-string-test.js index 8ee68daf3..91433ffff 100644 --- a/test/util/core/function-to-string-test.js +++ b/test/util/core/function-to-string-test.js @@ -7,7 +7,7 @@ var assert = referee.assert; describe("util/core/functionToString", function () { it("returns function's displayName property", function () { - var fn = function () {}; + var fn = function () { return; }; fn.displayName = "Larry"; assert.equals(functionToString.call(fn), "Larry"); diff --git a/test/util/core/get-next-tick-test.js b/test/util/core/get-next-tick-test.js index 90efe66d4..3c0a90ba1 100644 --- a/test/util/core/get-next-tick-test.js +++ b/test/util/core/get-next-tick-test.js @@ -7,14 +7,14 @@ var assert = referee.assert; describe("util/core/get-next-tick", function () { it("should use process.nextTick when available", function () { var mockProcess = { - nextTick: function () {} + nextTick: function () { return; } }; assert.same(getNextTick(mockProcess), mockProcess.nextTick); }); it("should use setImmediate when process.nextTick is not available", function () { - function mockSetImmediate() {} + function mockSetImmediate() { return; } assert.same(getNextTick(undefined, mockSetImmediate), mockSetImmediate); }); diff --git a/test/util/core/restore-test.js b/test/util/core/restore-test.js index 2f971567c..8e33635b5 100644 --- a/test/util/core/restore-test.js +++ b/test/util/core/restore-test.js @@ -7,9 +7,9 @@ var assert = referee.assert; describe("util/core/restore", function () { it("restores all methods of supplied object", function () { - var methodA = function () {}; - var methodB = function () {}; - var nonEnumerableMethod = function () {}; + var methodA = function () { return; }; + var methodB = function () { return; }; + var nonEnumerableMethod = function () { return; }; var obj = { methodA: methodA, methodB: methodB, nonEnumerableMethod: nonEnumerableMethod }; Object.defineProperty(obj, "nonEnumerableMethod", { enumerable: false @@ -24,8 +24,8 @@ describe("util/core/restore", function () { }); it("only restores restorable methods", function () { - var stubbedMethod = function () {}; - var vanillaMethod = function () {}; + var stubbedMethod = function () { return; }; + var vanillaMethod = function () { return; }; var obj = { stubbedMethod: stubbedMethod, vanillaMethod: vanillaMethod }; createStub(obj, "stubbedMethod"); @@ -35,7 +35,7 @@ describe("util/core/restore", function () { }); it("restores a single stubbed method", function () { - var method = function () {}; + var method = function () { return; }; var obj = { method: method }; createStub(obj); diff --git a/test/util/core/typeOf-test.js b/test/util/core/typeOf-test.js index 458cf5b9b..e9f93fe21 100644 --- a/test/util/core/typeOf-test.js +++ b/test/util/core/typeOf-test.js @@ -22,7 +22,7 @@ describe("typeOf", function () { }); it("returns function", function () { - assert.equals(sinonTypeOf(function () {}), "function"); + assert.equals(sinonTypeOf(function () { return; }), "function"); }); it("returns undefined", function () { diff --git a/test/util/core/walk-test.js b/test/util/core/walk-test.js index d81d63bf5..f8f3f1332 100644 --- a/test/util/core/walk-test.js +++ b/test/util/core/walk-test.js @@ -85,7 +85,7 @@ describe("util/core/walk", function () { }); it("should not invoke getters on the original receiving object", function () { - var Target = function Target() {}; + var Target = function Target() { return; }; var getter = createSpy(); Object.defineProperty(Target.prototype, "computedFoo", { enumerable: true, @@ -141,10 +141,10 @@ describe("util/core/walk", function () { it("does not walk the same property twice", function () { var parent = { - func: function parentFunc() {} + func: function parentFunc() { return; } }; var child = Object.create(parent); - child.func = function childFunc() {}; + child.func = function childFunc() { return; }; var iterator = createSpy(); walk(child, iterator); diff --git a/test/util/core/wrap-method-test.js b/test/util/core/wrap-method-test.js index cccb1f604..b428e293d 100644 --- a/test/util/core/wrap-method-test.js +++ b/test/util/core/wrap-method-test.js @@ -9,9 +9,9 @@ var refute = referee.refute; describe("util/core/wrapMethod", function () { beforeEach(function () { - this.method = function () {}; - this.getter = function () {}; - this.setter = function () {}; + this.method = function () { return; }; + this.getter = function () { return; }; + this.setter = function () { return; }; this.object = {method: this.method}; Object.defineProperty(this.object, "property", { get: this.getter, @@ -35,7 +35,7 @@ describe("util/core/wrapMethod", function () { var object = this.object; assert.exception(function () { - wrapMethod(object, "prop", function () {}); + wrapMethod(object, "prop", function () { return; }); }, {name: "TypeError"}); }); @@ -46,7 +46,7 @@ describe("util/core/wrapMethod", function () { object[symbol] = 42; assert.exception(function () { - wrapMethod(object, symbol, function () {}); + wrapMethod(object, symbol, function () { return; }); }, function (err) { return err.message === "Attempted to wrap number property Symbol() as function"; }); @@ -57,12 +57,12 @@ describe("util/core/wrapMethod", function () { var object = this.object; assert.exception(function () { - wrapMethod(object, "prop", function () {}); + wrapMethod(object, "prop", function () { return; }); }); assert.exception( function () { - wrapMethod(object, "prop", function () {}); + wrapMethod(object, "prop", function () { return; }); }, { message: /Attempted to wrap .* property .* as function/ @@ -87,14 +87,14 @@ describe("util/core/wrapMethod", function () { }); it("replaces object method", function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); refute.same(this.method, this.object.method); assert.isFunction(this.object.method); }); it("replaces getter", function () { - wrapMethod(this.object, "property", { get: function () {} }); + wrapMethod(this.object, "property", { get: function () { return; } }); refute.same(this.getter, Object.getOwnPropertyDescriptor(this.object, "property").get); assert.isFunction(Object.getOwnPropertyDescriptor(this.object, "property").get); @@ -102,7 +102,7 @@ describe("util/core/wrapMethod", function () { it("replaces setter", function () { wrapMethod(this.object, "property", { // eslint-disable-line accessor-pairs - set: function () {} + set: function () { return; } }); refute.same(this.setter, Object.getOwnPropertyDescriptor(this.object, "property").set); @@ -110,10 +110,10 @@ describe("util/core/wrapMethod", function () { }); it("throws if method is already wrapped", function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); assert.exception(function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); }, {name: "TypeError"}); }); @@ -121,11 +121,11 @@ describe("util/core/wrapMethod", function () { if (typeof Symbol === "function") { var symbol = Symbol(); var object = {}; - object[symbol] = function () {}; - wrapMethod(object, symbol, function () {}); + object[symbol] = function () { return; }; + wrapMethod(object, symbol, function () { return; }); assert.exception(function () { - wrapMethod(object, symbol, function () {}); + wrapMethod(object, symbol, function () { return; }); }, function (err) { return err.message === "Attempted to wrap Symbol() which is already wrapped"; }); @@ -133,10 +133,10 @@ describe("util/core/wrapMethod", function () { }); it("throws if property descriptor is already wrapped", function () { - wrapMethod(this.object, "property", { get: function () {} }); + wrapMethod(this.object, "property", { get: function () { return; } }); assert.exception(function () { - wrapMethod(this.object, "property", { get: function () {} }); + wrapMethod(this.object, "property", { get: function () { return; } }); }, {name: "TypeError"}); }); @@ -144,7 +144,7 @@ describe("util/core/wrapMethod", function () { var object = { method: createSpy() }; assert.exception(function () { - wrapMethod(object, "method", function () {}); + wrapMethod(object, "method", function () { return; }); }, {name: "TypeError"}); }); @@ -155,7 +155,7 @@ describe("util/core/wrapMethod", function () { object[symbol] = createSpy(); assert.exception(function () { - wrapMethod(object, symbol, function () {}); + wrapMethod(object, symbol, function () { return; }); }, function (err) { return err.message === "Attempted to wrap Symbol() which is already spied on"; }); @@ -183,14 +183,14 @@ describe("util/core/wrapMethod", function () { }); it("throws with stack trace showing original wrapMethod call", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; wrapMethod(object, "method", function () { return "original"; }); assert.exception( function () { - wrapMethod(object, "method", function () {}); + wrapMethod(object, "method", function () { return; }); }, { stack: ":STACK2:\n--------------\n:STACK1:" @@ -202,25 +202,25 @@ describe("util/core/wrapMethod", function () { if (typeof window !== "undefined") { describe("in browser", function () { it("does not throw if object is window object", function () { - window.sinonTestMethod = function () {}; + window.sinonTestMethod = function () { return; }; refute.exception(function () { - wrapMethod(window, "sinonTestMethod", function () {}); + wrapMethod(window, "sinonTestMethod", function () { return; }); }); }); }); } it("mirrors function properties", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; object.method.prop = 42; - wrapMethod(object, "method", function () {}); + wrapMethod(object, "method", function () { return; }); assert.equals(object.method.prop, 42); }); it("does not mirror and overwrite existing properties", function () { - var object = { method: function () {} }; + var object = { method: function () { return; } }; object.method.called = 42; createStub(object, "method"); @@ -230,24 +230,24 @@ describe("util/core/wrapMethod", function () { describe("wrapped method", function () { beforeEach(function () { - this.method = function () {}; + this.method = function () { return; }; this.object = { method: this.method }; }); it("defines restore method", function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); assert.isFunction(this.object.method.restore); }); it("returns wrapper", function () { - var wrapper = wrapMethod(this.object, "method", function () {}); + var wrapper = wrapMethod(this.object, "method", function () { return; }); assert.same(this.object.method, wrapper); }); it("restore brings back original method", function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); this.object.method.restore(); assert.same(this.object.method, this.method); @@ -256,21 +256,21 @@ describe("util/core/wrapMethod", function () { describe("wrapped prototype method", function () { beforeEach(function () { - this.type = function () {}; - this.type.prototype.method = function () {}; + this.type = function () { return; }; + this.type.prototype.method = function () { return; }; this.object = new this.type(); //eslint-disable-line new-cap }); it("wrap adds owned property", function () { - var wrapper = wrapMethod(this.object, "method", function () {}); + var wrapper = wrapMethod(this.object, "method", function () { return; }); assert.same(this.object.method, wrapper); assert(this.object.hasOwnProperty("method")); }); it("restore removes owned property", function () { - wrapMethod(this.object, "method", function () {}); + wrapMethod(this.object, "method", function () { return; }); this.object.method.restore(); assert.same(this.object.method, this.type.prototype.method); diff --git a/test/util/fake-timers-test.js b/test/util/fake-timers-test.js index be7151cda..7df6685e5 100644 --- a/test/util/fake-timers-test.js +++ b/test/util/fake-timers-test.js @@ -103,7 +103,7 @@ describe("fakeTimers.clock", function () { }); it("returns numeric id or object with numeric id", function () { - var result = this.clock.setImmediate(function () { }); + var result = this.clock.setImmediate(function () { return; }); if (typeof result === "object") { assert.isNumber(result.id); @@ -639,8 +639,8 @@ describe("fakeTimers.clock", function () { var realDate = new Date(); // eslint-disable-next-line no-global-assign - Date = function () {}; - this.global.Date = function () {}; + Date = function () { return; }; + this.global.Date = function () { return; }; var date = new this.clock.Date(); @@ -892,7 +892,7 @@ describe("fakeTimers.clock", function () { var to = setTimeout(stub, 1000); - if (typeof (setTimeout(function () {}, 0)) === "object") { + if (typeof (setTimeout(function () { return; }, 0)) === "object") { assert.isNumber(to.id); assert.isFunction(to.ref); assert.isFunction(to.unref); @@ -976,7 +976,7 @@ describe("fakeTimers.clock", function () { it("deletes global property on restore if it was inherited onto the global object", function () { // Give the global object an inherited 'tick' method delete this.global.tick; - this.global.__proto__.tick = function () { }; + this.global.__proto__.tick = function () { return; }; if (!this.global.hasOwnProperty("tick")) { this.clock = fakeTimers.useFakeTimers({toFake: ["tick"]}); @@ -995,7 +995,7 @@ describe("fakeTimers.clock", function () { it("restores global property on restore if it is present on the global object itself", function () { // Directly give the global object a tick method - this.global.tick = function () { }; + this.global.tick = function () { return; }; this.clock = fakeTimers.useFakeTimers({toFake: ["tick"]}); assert.isTrue(this.global.hasOwnProperty("tick")); @@ -1021,7 +1021,7 @@ describe("fakeTimers.clock", function () { }); it("decide on Date.now support at call-time when supported", function () { - this.global.Date.now = function () {}; + this.global.Date.now = function () { return; }; this.clock = fakeTimers.useFakeTimers(0); assert.equals(typeof Date.now, "function"); @@ -1035,7 +1035,7 @@ describe("fakeTimers.clock", function () { }); it("mirrors custom Date properties", function () { - var f = function () { }; + var f = function () { return; }; this.global.Date.format = f; fakeTimers.useFakeTimers();