Skip to content

Commit

Permalink
diffJson: Test that a circular reference causes JSON.stringify to thr…
Browse files Browse the repository at this point in the history
…ow (rather than an infinite loop).
  • Loading branch information
papandreou committed Sep 4, 2014
1 parent a9191cb commit d786a63
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/diffTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ describe('#diffJson', function() {
{a: 123, b: 456, c: 789});
diff.convertChangesToXML(diffResult).should.equal('{\n &quot;a&quot;: 123,\n &quot;b&quot;: 456,\n<ins> &quot;c&quot;: 789\n</ins>}');
});

it('should throw an error if one of the objects being diffed has a circular reference', function() {
var circular = {foo: 123};
circular.bar = circular;
(function () {
diff.diffJson(
circular,
{foo: 123, bar: {}}
);
}).should.throw('Converting circular structure to JSON');
});
});

describe('convertToDMP', function() {
Expand Down

0 comments on commit d786a63

Please sign in to comment.