Skip to content

Commit

Permalink
Merge pull request #15 from reinseth/match-dates
Browse files Browse the repository at this point in the history
Match dates
  • Loading branch information
cjohansen committed Oct 2, 2017
2 parents 7dbefcc + 65e0843 commit 1f6208b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
before_install:
Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "5"

Expand Down
4 changes: 4 additions & 0 deletions lib/samsam.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@
return arrayContains(object, matcher, match);
}

if (isDate(matcher)) {
return isDate(object) && object.getTime() === matcher.getTime();
}

if (matcher && typeof matcher === "object") {
if (matcher === object) {
return true;
Expand Down
6 changes: 6 additions & 0 deletions test/samsam-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ if (typeof module === "object" && typeof require === "function") {
}])
);
}

var date = new Date();
var sameDate = new Date(date.getTime());
var anotherDate = new Date(date.getTime() - 10);
pass("date objects with same date", date, sameDate);
fail("date objects with different dates", date, anotherDate);
});

tests("isArguments", function (pass, fail) {
Expand Down

0 comments on commit 1f6208b

Please sign in to comment.