From: Jan Tagscherer <3198913+jtagscherer@users.noreply.github.com> Date: Wed, 14 Nov 2018 10:08:40 +0000 (+0100) Subject: Check pixel values using the pixel proximity matcher (#5833) X-Git-Tag: v2.8.0-rc.1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56b30e1db1f9f1efa2f23b085f5604b489020883;p=thirdparty%2FChart.js.git Check pixel values using the pixel proximity matcher (#5833) --- diff --git a/test/specs/scale.logarithmic.tests.js b/test/specs/scale.logarithmic.tests.js index 3d79e6cfc..cb44f108d 100644 --- a/test/specs/scale.logarithmic.tests.js +++ b/test/specs/scale.logarithmic.tests.js @@ -822,8 +822,8 @@ describe('Logarithmic Scale tests', function() { var start = chart.chartArea[chartStart]; var end = chart.chartArea[chartEnd]; - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4); @@ -835,8 +835,8 @@ describe('Logarithmic Scale tests', function() { start = chart.chartArea[chartEnd]; end = chart.chartArea[chartStart]; - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4); @@ -964,9 +964,9 @@ describe('Logarithmic Scale tests', function() { var start = chart.chartArea[axis.start]; var end = chart.chartArea[axis.end]; - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); - expect(scale.getPixelForValue(0, 0, 0)).toBe(start); // 0 is invalid, put it at the start. + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); + expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start); // 0 is invalid, put it at the start. expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4); @@ -978,8 +978,8 @@ describe('Logarithmic Scale tests', function() { start = chart.chartArea[axis.end]; end = chart.chartArea[axis.start]; - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4); @@ -1093,9 +1093,9 @@ describe('Logarithmic Scale tests', function() { var end = chart.chartArea[axis.end]; var sign = scale.isHorizontal() ? 1 : -1; - expect(scale.getPixelForValue(0, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start + sign * fontSize); + expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start + sign * fontSize); expect(scale.getValueForPixel(start)).toBeCloseTo(0, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4); @@ -1108,9 +1108,9 @@ describe('Logarithmic Scale tests', function() { start = chart.chartArea[axis.end]; end = chart.chartArea[axis.start]; - expect(scale.getPixelForValue(0, 0, 0)).toBe(start); - expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end); - expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start - sign * fontSize, 4); + expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start); + expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); + expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start - sign * fontSize, 4); expect(scale.getValueForPixel(start)).toBeCloseTo(0, 4); expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);