From 6f18350eda5d93e4f4d6ebaf94a5ecab904a5955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Tue, 18 Feb 2020 15:19:51 +0100 Subject: [PATCH] Add regression test for image opacity --- test/spec/ol/render/canvas/index.test.js | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/spec/ol/render/canvas/index.test.js b/test/spec/ol/render/canvas/index.test.js index 58a4a5551d..01589ec3a2 100644 --- a/test/spec/ol/render/canvas/index.test.js +++ b/test/spec/ol/render/canvas/index.test.js @@ -100,4 +100,34 @@ describe('ol.render.canvas', function() { }); }); + describe('drawImageOrLabel', function() { + it('draws the image with correct parameters', function() { + const layerContext = { + save: sinon.spy(), + setTransform: sinon.spy(), + drawImage: sinon.spy(), + restore: sinon.spy(), + globalAlpha: 1 + }; + const transform = [1, 0, 0, 1, 0, 0]; + const opacity = 0.5; + const image = {}; + const x = 0; + const y = 0; + const w = 1; + const h = 1; + const scale = 1; + + render.drawImageOrLabel(layerContext, transform.slice(), opacity, image, + x, y, w, h, x, y, scale); + + expect(layerContext.save.callCount).to.be(1); + expect(layerContext.setTransform.callCount).to.be(1); + expect(layerContext.setTransform.firstCall.args).to.eql(transform); + expect(layerContext.drawImage.callCount).to.be(1); + expect(layerContext.globalAlpha).to.be(.5); + expect(layerContext.restore.callCount).to.be(1); + }); + }); + });