From 51ef466afb12c3ec63640e3a01848d5815506aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slobodan=20Mi=C5=A1kovi=C4=87?= Date: Sun, 4 Sep 2016 21:56:51 -0700 Subject: [PATCH 1/2] Better diff output when comparing This shows a better diff of which keys are extra/missing rather than getting big strings dumped on the user --- chai-immutable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chai-immutable.js b/chai-immutable.js index 72351ac..eb85b79 100644 --- a/chai-immutable.js +++ b/chai-immutable.js @@ -105,8 +105,8 @@ Immutable.is(obj, collection), 'expected #{act} to equal #{exp}', 'expected #{act} to not equal #{exp}', - collection.toString(), - obj.toString(), + collection.toJS(), + obj.toJS(), true ); } From d206afc81814b46c4c7dcf169941f17810c6e863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slobodan=20Mi=C5=A1kovi=C4=87?= Date: Mon, 9 Jan 2017 15:49:00 -0800 Subject: [PATCH 2/2] Fix tests for diff output when comparing objects --- test/test.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index be84768..a5a09f6 100644 --- a/test/test.js +++ b/test/test.js @@ -146,9 +146,16 @@ describe('chai-immutable (' + typeEnv + ')', function () { it('should display a helpful failure output on big objects', function () { var actual = new Map({ foo: 'foo foo foo foo foo foo foo foo' }); var expected = new Map({ bar: 'bar bar bar bar bar bar bar bar' }); + // AssertionError: expected { Object (foo) } to equal { Object (bar) } + // + expected - actual + // + // { + // - "foo": "foo foo foo foo foo foo foo foo" + // + "bar": "bar bar bar bar bar bar bar bar" + // } fail(function () { expect(actual).to.equal(expected); - }, /(foo ?){8}.+(bar ?){8}/); + }, 'AssertionError: expected { Object (foo) } to equal { Object (bar) }'); }); it('should fail given a non-Immutable value', function () { @@ -749,9 +756,16 @@ describe('chai-immutable (' + typeEnv + ')', function () { it('should display a helpful failure output on big objects', function () { var actual = new Map({ foo: 'foo foo foo foo foo foo foo foo ' }); var expected = new Map({ bar: 'bar bar bar bar bar bar bar bar ' }); + // AssertionError: expected { Object (foo) } to equal { Object (bar) } + // + expected - actual + // + // { + // - "foo": "foo foo foo foo foo foo foo foo" + // + "bar": "bar bar bar bar bar bar bar bar" + // } fail(function () { assert.equal(actual, expected); - }, /(foo ){8}.+(bar ){8}/); + }, 'AssertionError: expected { Object (foo) } to equal { Object (bar) }'); }); it('should fail given a non-Immutable value', function () {