From 138dafc6bbad428aff4072ea5567cfd8c1a81fb1 Mon Sep 17 00:00:00 2001 From: Brent McSharry <2456704+mcshaz@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:16:00 +1300 Subject: [PATCH 1/3] Update test.js --- test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test.js b/test.js index f9c73ae..828f13e 100644 --- a/test.js +++ b/test.js @@ -39,6 +39,21 @@ describe('chaiAlmost', function () { expect(good).to.be.deep.almost(exp) expect(bad).to.not.be.deep.almost(exp) }) + + it('should modify deep-deep equality checks on arrays & objects to allow default tolerance for numbers', function () { + var exp = [{ taco: 'pastor', quantity: 3 }, + { taco: 'pastor', quantity: [{a:2,b:1}], ref:[3,4] }]; + var good = [{ taco: 'pastor', quantity: 2.9999999 }, + { taco: 'pastor', quantity: [{ a:1.9999999,b:0.9999999 }, ref:[2.9999999, 3.0000001]]; + var bad1 = [{ taco: 'pastor', quantity: 3 }, + { taco: 'pastor', quantity: [{a:2.1,b:1}] }, ref[3,4]]; + var bad2 = [{ taco: 'pastor', quantity: 3 }, + { taco: 'pastor', quantity: [{a:2,b:1}] }, ref[3.1,4]]; + + expect(good).to.be.deep.almost(exp) + expect(bad1).to.not.be.deep.almost(exp) + expect(bad2).to.not.be.deep.almost(exp) + }) it('should modify deep equality checks to allow custom tolerance for numbers', function () { var exp = { taco: 'pastor', quantity: 10 } From 4328acb6301f39101dd064fe683d21e4b661d17e Mon Sep 17 00:00:00 2001 From: Brent McSharry <2456704+mcshaz@users.noreply.github.com> Date: Sun, 17 Mar 2019 16:43:17 +1300 Subject: [PATCH 2/3] array checks --- test.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test.js b/test.js index 828f13e..9e2bd73 100644 --- a/test.js +++ b/test.js @@ -30,17 +30,17 @@ describe('chaiAlmost', function () { }) }) - describe('with deep equality', function () { - it('should modify deep equality checks to allow default tolerance for numbers', function () { - var exp = { taco: 'pastor', quantity: 3 } - var good = { taco: 'pastor', quantity: 2.9999999 } - var bad = { taco: 'pastor', quantity: 3.1 } - - expect(good).to.be.deep.almost(exp) - expect(bad).to.not.be.deep.almost(exp) + describe('with array equality', function () { + it('should modify array equality checks to allow default tolerance for numbers', function () { + var exp = ['pastor', 3 ]; + var good = ['pastor', 2.9999999 ]; + var bad = [ 'pastor', 3.1 ]; + + expect(good).to.be.deep.almost(exp); + expect(bad).to.not.be.deep.almost(exp); }) - it('should modify deep-deep equality checks on arrays & objects to allow default tolerance for numbers', function () { + it('should modify deep-deep equality checks on arrays with objects objects with default tolerance', function () { var exp = [{ taco: 'pastor', quantity: 3 }, { taco: 'pastor', quantity: [{a:2,b:1}], ref:[3,4] }]; var good = [{ taco: 'pastor', quantity: 2.9999999 }, @@ -54,7 +54,18 @@ describe('chaiAlmost', function () { expect(bad1).to.not.be.deep.almost(exp) expect(bad2).to.not.be.deep.almost(exp) }) + }) + + describe('with deep equality', function () { + it('should modify deep equality checks on objects to allow default tolerance for numbers', function () { + var exp = { taco: 'pastor', quantity: 3 } + var good = { taco: 'pastor', quantity: 2.9999999 } + var bad = { taco: 'pastor', quantity: 3.1 } + expect(good).to.be.deep.almost(exp) + expect(bad).to.not.be.deep.almost(exp) + }) + it('should modify deep equality checks to allow custom tolerance for numbers', function () { var exp = { taco: 'pastor', quantity: 10 } var good = { taco: 'pastor', quantity: 29 } From 7e43790199603b7ab9fd76e55482fa82043bec7b Mon Sep 17 00:00:00 2001 From: Brent McSharry <2456704+mcshaz@users.noreply.github.com> Date: Sun, 17 Mar 2019 17:57:28 +1300 Subject: [PATCH 3/3] fix brackets --- test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test.js b/test.js index 9e2bd73..3896902 100644 --- a/test.js +++ b/test.js @@ -42,13 +42,13 @@ describe('chaiAlmost', function () { it('should modify deep-deep equality checks on arrays with objects objects with default tolerance', function () { var exp = [{ taco: 'pastor', quantity: 3 }, - { taco: 'pastor', quantity: [{a:2,b:1}], ref:[3,4] }]; + { taco: 'pastor', quantity: [{a:2,b:1}, {ref:[3,4]} ]]; var good = [{ taco: 'pastor', quantity: 2.9999999 }, - { taco: 'pastor', quantity: [{ a:1.9999999,b:0.9999999 }, ref:[2.9999999, 3.0000001]]; + { taco: 'pastor', quantity: [{ a:1.9999999,b:0.9999999 }, {ref:[2.9999999, 3.0000001]}]]; var bad1 = [{ taco: 'pastor', quantity: 3 }, - { taco: 'pastor', quantity: [{a:2.1,b:1}] }, ref[3,4]]; + { taco: 'pastor', quantity: [{a:2.1,b:1}] }, { ref:[3,4]}]]; var bad2 = [{ taco: 'pastor', quantity: 3 }, - { taco: 'pastor', quantity: [{a:2,b:1}] }, ref[3.1,4]]; + { taco: 'pastor', quantity: [{a:2,b:1}] }, {ref:[3.1,4]}]]; expect(good).to.be.deep.almost(exp) expect(bad1).to.not.be.deep.almost(exp)