Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix failing Magna Charta test in Safari #4661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ describe('Magna charta', function () {
// widths are 65/max * val (65 by default)
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 + '%'
var width = ((65 / max) * val + padding)
return `${width}%`
}

var single =
Expand Down Expand Up @@ -282,12 +276,15 @@ describe('Magna charta', function () {

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))

for (var cell of cells) {
var cellText = cell.textContent
var cellWidth = cell.style.width
var calculatedWidth = parseFloat(cW(12, cellText))

expect(cellWidth).toContain('%')
expect(parseFloat(cellWidth)).toBeCloseTo(calculatedWidth, 4)
}
})

it('the bar cells are given classes denoting their index', function () {
Expand Down