Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deeper object testing #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,42 @@ 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 }

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 }
Expand Down