Skip to content

Commit

Permalink
Merge pull request chaijs#22 from debitoor/compare-dates
Browse files Browse the repository at this point in the history
Comparison of Dates
  • Loading branch information
eagleeye authored and koddsson committed Dec 2, 2015
1 parent bba9adf commit 0fe59da
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/unit/chai-subset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,30 @@ describe('assert style of test', function () {
var assert = require('chai').assert;
assert.containSubset({a: 1, b: 2}, {a: 1});
});
});

describe('comparison of dates', function() {
it('should pass for the same date', function() {
expect(new Date('2015-11-30')).to.containSubset(new Date('2015-11-30'));
});

it('should pass for the same date if nested', function() {
expect({a: new Date('2015-11-30')}).to.containSubset({a: new Date('2015-11-30')});
});

it('should fail for a different date', function() {
expect(new Date('2015-11-30')).to.not.containSubset(new Date('2012-02-22'));
});

it('should fail for a different date if nested', function() {
expect({a: new Date('2015-11-30')}).to.not.containSubset({a: new Date('2012-02-22')});
});

it('should fail for invalid expected date', function() {
expect(new Date('2015-11-30')).to.not.containSubset(new Date('not valid date'));
});

it('should fail for invalid actual date', function() {
expect(new Date('not valid actual date')).to.not.containSubset(new Date('not valid expected date'));
});
});

0 comments on commit 0fe59da

Please sign in to comment.