Skip to content

Magna charta test failing in Safari 14.1.1 #2229

@injms

Description

@injms

It looks as if Safari rounds differently to other browsers, which causes a test for Magna Charta to fail.

Failing test:

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:

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 + '%'
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions