Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check pixel values within the logarithmic scale unit test using the pixel proximity matcher #5833

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions test/specs/scale.logarithmic.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down