diff --git a/test.js b/test.js index f9c73ae..3896902 100644 --- a/test.js +++ b/test.js @@ -30,8 +30,34 @@ describe('chaiAlmost', function () { }) }) + 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 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 }, + { 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) + }) + }) + describe('with deep equality', function () { - it('should modify deep equality checks to allow default tolerance for numbers', 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 } @@ -39,7 +65,7 @@ describe('chaiAlmost', function () { 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 }