Skip to content

Commit

Permalink
Fix tests on OSX with retina screen
Browse files Browse the repository at this point in the history
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result
  • Loading branch information
andig authored and etimberg committed Aug 5, 2017
1 parent 9ef5cc7 commit 8dca88c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions test/jasmine.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/specs/platform.dom.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit 8dca88c

Please sign in to comment.