From 3e95c424abd1a4b9acaf872a02f1e7c3cd6a34cb Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 8 Mar 2017 15:37:45 +0100 Subject: [PATCH] Don't use deprecated sinon.stub(obj, 'meth', fn) Code updated using https://github.com/hurrymaplelad/sinon-codemod --- test/spec/ol/renderer/vector.test.js | 20 +++++++------------- test/spec/ol/tileurlfunction.test.js | 6 +++--- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/test/spec/ol/renderer/vector.test.js b/test/spec/ol/renderer/vector.test.js index 71137d77b7..3e9242da2e 100644 --- a/test/spec/ol/renderer/vector.test.js +++ b/test/spec/ol/renderer/vector.test.js @@ -37,7 +37,7 @@ describe('ol.renderer.vector', function() { squaredTolerance = 1; listener = function() {}; listenerThis = {}; - iconStyleLoadSpy = sinon.stub(iconStyle, 'load', function() { + iconStyleLoadSpy = sinon.stub(iconStyle, 'load').callsFake(function() { iconStyle.iconImage_.imageState_ = 1; // LOADING }); }); @@ -79,8 +79,7 @@ describe('ol.renderer.vector', function() { var imageReplay = replayGroup.getReplay( style.getZIndex(), 'Image'); var setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle'); - var drawPointSpy = sinon.stub(imageReplay, - 'drawPoint', ol.nullFunction); + var drawPointSpy = sinon.stub(imageReplay, 'drawPoint').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setImageStyleSpy.called).to.be(false); @@ -93,8 +92,7 @@ describe('ol.renderer.vector', function() { var imageReplay = replayGroup.getReplay( style.getZIndex(), 'Image'); var setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle'); - var drawMultiPointSpy = sinon.stub(imageReplay, - 'drawMultiPoint', ol.nullFunction); + var drawMultiPointSpy = sinon.stub(imageReplay, 'drawMultiPoint').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setImageStyleSpy.called).to.be(false); @@ -108,8 +106,7 @@ describe('ol.renderer.vector', function() { style.getZIndex(), 'LineString'); var setFillStrokeStyleSpy = sinon.spy(lineStringReplay, 'setFillStrokeStyle'); - var drawLineStringSpy = sinon.stub(lineStringReplay, - 'drawLineString', ol.nullFunction); + var drawLineStringSpy = sinon.stub(lineStringReplay, 'drawLineString').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); @@ -124,8 +121,7 @@ describe('ol.renderer.vector', function() { style.getZIndex(), 'LineString'); var setFillStrokeStyleSpy = sinon.spy(lineStringReplay, 'setFillStrokeStyle'); - var drawMultiLineStringSpy = sinon.stub(lineStringReplay, - 'drawMultiLineString', ol.nullFunction); + var drawMultiLineStringSpy = sinon.stub(lineStringReplay, 'drawMultiLineString').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); @@ -141,8 +137,7 @@ describe('ol.renderer.vector', function() { style.getZIndex(), 'Polygon'); var setFillStrokeStyleSpy = sinon.spy(polygonReplay, 'setFillStrokeStyle'); - var drawPolygonSpy = sinon.stub(polygonReplay, - 'drawPolygon', ol.nullFunction); + var drawPolygonSpy = sinon.stub(polygonReplay, 'drawPolygon').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); @@ -158,8 +153,7 @@ describe('ol.renderer.vector', function() { style.getZIndex(), 'Polygon'); var setFillStrokeStyleSpy = sinon.spy(polygonReplay, 'setFillStrokeStyle'); - var drawMultiPolygonSpy = sinon.stub(polygonReplay, - 'drawMultiPolygon', ol.nullFunction); + var drawMultiPolygonSpy = sinon.stub(polygonReplay, 'drawMultiPolygon').callsFake(ol.nullFunction); ol.renderer.vector.renderFeature(replayGroup, feature, style, squaredTolerance, listener, listenerThis); expect(setFillStrokeStyleSpy.called).to.be(true); diff --git a/test/spec/ol/tileurlfunction.test.js b/test/spec/ol/tileurlfunction.test.js index fcd920a35b..6d795b9616 100644 --- a/test/spec/ol/tileurlfunction.test.js +++ b/test/spec/ol/tileurlfunction.test.js @@ -93,19 +93,19 @@ describe('ol.TileUrlFunction', function() { var tileCoord = [3, 2, -2]; /* eslint-disable openlayers-internal/no-missing-requires */ - sinon.stub(ol.tilecoord, 'hash', function() { + sinon.stub(ol.tilecoord, 'hash').callsFake(function() { return 3; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1'); ol.tilecoord.hash.restore(); - sinon.stub(ol.tilecoord, 'hash', function() { + sinon.stub(ol.tilecoord, 'hash').callsFake(function() { return 2; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-3/3/2/1'); ol.tilecoord.hash.restore(); - sinon.stub(ol.tilecoord, 'hash', function() { + sinon.stub(ol.tilecoord, 'hash').callsFake(function() { return 1; }); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-2/3/2/1');