Skip to content

Commit 20dc8fc

Browse files
jtagscherersimonbrunel
authored andcommitted
Check pixel values using the pixel proximity matcher (chartjs#5833)
1 parent bcd4529 commit 20dc8fc

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/specs/scale.logarithmic.tests.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ describe('Logarithmic Scale tests', function() {
822822
var start = chart.chartArea[chartStart];
823823
var end = chart.chartArea[chartEnd];
824824

825-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start);
826-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
825+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start);
826+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
827827

828828
expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4);
829829
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);
@@ -835,8 +835,8 @@ describe('Logarithmic Scale tests', function() {
835835
start = chart.chartArea[chartEnd];
836836
end = chart.chartArea[chartStart];
837837

838-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start);
839-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
838+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start);
839+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
840840

841841
expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4);
842842
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);
@@ -964,9 +964,9 @@ describe('Logarithmic Scale tests', function() {
964964
var start = chart.chartArea[axis.start];
965965
var end = chart.chartArea[axis.end];
966966

967-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start);
968-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
969-
expect(scale.getPixelForValue(0, 0, 0)).toBe(start); // 0 is invalid, put it at the start.
967+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start);
968+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
969+
expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start); // 0 is invalid, put it at the start.
970970

971971
expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4);
972972
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);
@@ -978,8 +978,8 @@ describe('Logarithmic Scale tests', function() {
978978
start = chart.chartArea[axis.end];
979979
end = chart.chartArea[axis.start];
980980

981-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start);
982-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
981+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start);
982+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
983983

984984
expect(scale.getValueForPixel(start)).toBeCloseTo(firstTick, 4);
985985
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);
@@ -1093,9 +1093,9 @@ describe('Logarithmic Scale tests', function() {
10931093
var end = chart.chartArea[axis.end];
10941094
var sign = scale.isHorizontal() ? 1 : -1;
10951095

1096-
expect(scale.getPixelForValue(0, 0, 0)).toBe(start);
1097-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
1098-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start + sign * fontSize);
1096+
expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start);
1097+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
1098+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start + sign * fontSize);
10991099

11001100
expect(scale.getValueForPixel(start)).toBeCloseTo(0, 4);
11011101
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);
@@ -1108,9 +1108,9 @@ describe('Logarithmic Scale tests', function() {
11081108
start = chart.chartArea[axis.end];
11091109
end = chart.chartArea[axis.start];
11101110

1111-
expect(scale.getPixelForValue(0, 0, 0)).toBe(start);
1112-
expect(scale.getPixelForValue(lastTick, 0, 0)).toBe(end);
1113-
expect(scale.getPixelForValue(firstTick, 0, 0)).toBe(start - sign * fontSize, 4);
1111+
expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start);
1112+
expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end);
1113+
expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start - sign * fontSize, 4);
11141114

11151115
expect(scale.getValueForPixel(start)).toBeCloseTo(0, 4);
11161116
expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick, 4);

0 commit comments

Comments
 (0)