From bf4fdcff86d11ef78c35c823732f6f8d8e06f288 Mon Sep 17 00:00:00 2001 From: Guy Baron Date: Thu, 15 Dec 2022 14:04:48 -0500 Subject: [PATCH] test: validate the canvas style too --- test/specs/helpers.dom.tests.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/specs/helpers.dom.tests.js b/test/specs/helpers.dom.tests.js index 1d0fa6ed8..06db1c4da 100644 --- a/test/specs/helpers.dom.tests.js +++ b/test/specs/helpers.dom.tests.js @@ -254,7 +254,7 @@ describe('DOM helpers tests', function() { expect(canvas.style.width).toBe('400px'); }); - it ('retinaScale should not change chart size', function() { + it ('should handle devicePixelRatio correctly', function() { const chartWidth = 800; const chartHeight = 400; let devicePixelRatio = 0.8999999761581421; // 1.7999999523162842; @@ -262,19 +262,20 @@ describe('DOM helpers tests', function() { canvas: { width: chartWidth, height: chartHeight, - style: `width: ${chartWidth}px; height: ${chartHeight}px;` } }); - helpers.retinaScale(chart, devicePixelRatio, false); + helpers.retinaScale(chart, devicePixelRatio, true); var canvas = chart.canvas; - expect(canvas.width).toBe(Math.floor(chartWidth * devicePixelRatio)); expect(canvas.height).toBe(Math.floor(chartHeight * devicePixelRatio)); expect(chart.width).toBe(chartWidth); expect(chart.height).toBe(chartHeight); + + expect(canvas.style.width).toBe(`${chartWidth}px`); + expect(canvas.style.height).toBe(`${chartHeight}px`); }); describe('getRelativePosition', function() {