From 2fd8a556e143be02ec883215396c13012ad4fd59 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 14 Apr 2020 20:25:27 +0200 Subject: [PATCH] Better test for uniform colors --- test/spec/ol/reproj/image.test.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/spec/ol/reproj/image.test.js b/test/spec/ol/reproj/image.test.js index 1035372146..24e84842ad 100644 --- a/test/spec/ol/reproj/image.test.js +++ b/test/spec/ol/reproj/image.test.js @@ -103,10 +103,12 @@ describe('ol.reproj.Image', function () { .getImageData(0, 0, canvas.width, canvas.height).data; for (let i = 0; i < canvas.width * canvas.height * 4; i += 4) { - expect(pixels[i + 0]).to.be.within(pixels[0] - 2, pixels[0] + 2); - expect(pixels[i + 1]).to.be.within(pixels[1] - 2, pixels[1] + 2); - expect(pixels[i + 2]).to.be.within(pixels[2] - 2, pixels[2] + 2); - expect(pixels[i + 3]).to.be.within(pixels[3] - 2, pixels[3] + 2); + expect( + Math.abs(pixels[i + 0] - pixels[0]) + + Math.abs(pixels[i + 1] - pixels[1]) + + Math.abs(pixels[i + 2] - pixels[2]) + + Math.abs(pixels[i + 3] - pixels[3]) + ).to.be.lessThan(5); } done(); }