-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
It looks as if Safari rounds differently to other browsers, which causes a test for Magna Charta to fail.
Failing test:
Lines 269 to 277 in 8a45baa
it('the bar cells are given the right widths', function () { | |
var cells = graph.find('.mc-bar-cell') | |
expect(cells.get(0).style.width).toEqual(cW(12, 5)) | |
expect(cells.get(1).style.width).toEqual(cW(12, 6)) | |
expect(cells.get(2).style.width).toEqual(cW(12, 6)) | |
expect(cells.get(3).style.width).toEqual(cW(12, 2)) | |
expect(cells.get(4).style.width).toEqual(cW(12, 3)) | |
expect(cells.get(5).style.width).toEqual(cW(12, 9)) | |
}) |
The test fails with the error for line 272:
Expected '27.083333333333336%' to equal '27.0833%'.
and for line 275:
Expected '10.833333333333334%' to equal '10.8333%'.
which makes me think that the cW
helper function is the culprit:
Lines 15 to 25 in 8a45baa
var cW = function (max, val, padding) { | |
padding = padding || 0 | |
var result = ((65 / max) * val + padding).toString() | |
// truncate the result to only 4 digits after the decimal place | |
// e.g. 27.0833333333 becomes 27.0833, 27.1 and 27 remain the same | |
var split = result.split('.') | |
if (split.length > 1) { | |
result = split[0] + '.' + split[1].substring(0, 4) | |
} | |
return result + '%' | |
} |