From: andig Date: Sat, 5 Aug 2017 14:48:12 +0000 (+0200) Subject: Fix tests on OSX with retina screen X-Git-Tag: v2.7.0~1^2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4619%2Fhead;p=thirdparty%2FChart.js.git Fix tests on OSX with retina screen * Fix retina unit test failures * Honor config file formatting * Prevent gulp error on non-zero karma result --- 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); }); }); });