From 8dca88c7d52f9ec153e920eb2a89254f98b1d44d Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 5 Aug 2017 16:48:12 +0200 Subject: [PATCH] Fix tests on OSX with retina screen * Fix retina unit test failures * Honor config file formatting * Prevent gulp error on non-zero karma result --- .editorconfig | 8 ++++++++ gulpfile.js | 7 ++++++- test/jasmine.index.js | 4 ++++ test/specs/platform.dom.tests.js | 4 ++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4e0d877ef..8cea3b4f0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,11 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = false + +[gulpfile.js] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/gulpfile.js b/gulpfile.js index 2ae49d77d..bb42ea9d3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -188,7 +188,12 @@ function unittestTask(done) { args: { coverage: !!argv.coverage } - }, done).start(); + }, + // https://github.com/karma-runner/gulp-karma/issues/18 + function(error) { + error = error ? new Error('Karma returned with the error code: ' + error) : undefined; + done(error); + }).start(); } function librarySizeTask() { diff --git a/test/jasmine.index.js b/test/jasmine.index.js index 10e2e6177..7e5fd67be 100644 --- a/test/jasmine.index.js +++ b/test/jasmine.index.js @@ -22,6 +22,10 @@ var utils = require('./jasmine.utils'); return new Context(); } + // force ratio=1 for tests on high-res/retina devices + // fixes https://github.com/chartjs/Chart.js/issues/4515 + window.devicePixelRatio = 1; + window.acquireChart = acquireChart; window.releaseChart = releaseChart; window.waitForResize = utils.waitForResize; diff --git a/test/specs/platform.dom.tests.js b/test/specs/platform.dom.tests.js index 4358b9b35..d765109c4 100644 --- a/test/specs/platform.dom.tests.js +++ b/test/specs/platform.dom.tests.js @@ -394,8 +394,8 @@ describe('Platform.dom', function() { expect(notifiedEvent.type).toBe(evt.type); // Relative Position - expect(notifiedEvent.x).toBe(chart.width / 2); - expect(notifiedEvent.y).toBe(chart.height / 2); + expect(notifiedEvent.x).toBeCloseToPixel(chart.width / 2); + expect(notifiedEvent.y).toBeCloseToPixel(chart.height / 2); }); }); }); -- 2.47.2