HomePhabricator

QUnit.assert.equalHash: Correctly compare JSON representation

Description

QUnit.assert.equalHash: Correctly compare JSON representation

The object returned by Object#toJSON is not the JSON representation
yet: its values have to be recursively converted by calling #toJSON
on them too. For example, see ve.dm.LinearSelection#toJSON (the return
value of which includes an actual ve.Range object).

JSON.stringify takes care of this, but we didn't here, causing
the diffs shown by QUnit in case of test failures when comparing
ve.dm.LinearSelections to be polluted with ve.Range's functions.
(For example, try changing one of 'expectedRangeOrSelection' values
in ve.ui.LinkAction tests.)

Rather than reimplement this, just use JSON.stringify and JSON.parse.

Change-Id: Ie9153de8072433725e599a97a100a2a6d29e4192

Details