Skip to content

Commit

Permalink
Adding a compare function to be used in expected object template (cha…
Browse files Browse the repository at this point in the history
…ijs#66)

* Adding compare function to be used in expected object template

* Adding compare function example to README.md
  • Loading branch information
Sergej Shafarenka authored and koddsson committed Sep 5, 2017
1 parent 104982a commit 42f9483
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/chai-subset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ describe('circular objects', function() {
});
});

describe('object with compare function', function() {
it('should pass when function returns true', function () {
expect({a: 5}).to.containSubset({a: a => a});
});

it('should fail when function returns false', function () {
expect({a: 5}).to.not.containSubset({a: a => !a});
});

it('should pass for function with no arguments', function () {
expect({a: 5}).to.containSubset({a: () => true});
});
});

describe('comparison of non objects', function () {
it('should fail if actual subset is null', function () {
expect(null).to.not.containSubset({a: 1});
Expand Down

0 comments on commit 42f9483

Please sign in to comment.