Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Magna charta test failing in Safari 14.1.1 #2229

Open
injms opened this issue Jul 26, 2021 · 0 comments · May be fixed by #4661
Open

Magna charta test failing in Safari 14.1.1 #2229

injms opened this issue Jul 26, 2021 · 0 comments · May be fixed by #4661
Assignees
Labels
acknowledged This issue has been triaged. bug

Comments

@injms
Copy link
Contributor

injms commented Jul 26, 2021

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

@injms injms added the bug label Jul 26, 2021
@andysellick andysellick added the acknowledged This issue has been triaged. label Aug 4, 2022
@MartinJJones MartinJJones self-assigned this Feb 5, 2025
MartinJJones added a commit that referenced this issue Feb 28, 2025
- Updated the `cW` function to avoid truncating the calculated width, this matches the default behaviour in magnaCharta which does not restrict the number of decimal places
- Use the [toBeCloseTo](https://jasmine.github.io/api/5.6/matchers#toBeCloseTo) matcher and set the number of decimal points to check to 4

Fixes: #2229
@MartinJJones MartinJJones linked a pull request Feb 28, 2025 that will close this issue
MartinJJones added a commit that referenced this issue Feb 28, 2025
- Updated the `cW` function to avoid truncating the calculated width, this matches the default behaviour in magnaCharta which does not restrict the number of decimal places
- Use the [toBeCloseTo](https://jasmine.github.io/api/5.6/matchers#toBeCloseTo) matcher and set the number of decimal points to check to 4

Fixes: #2229
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
acknowledged This issue has been triaged. bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants