Skip to content

Commit 1f6208b

Browse files
authored
Merge pull request #15 from reinseth/match-dates
Match dates
2 parents 7dbefcc + 65e0843 commit 1f6208b

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- "0.10"
5-
- "0.12"
64
- "4"
75
- "5"
86
before_install:

appveyor.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
environment:
22
matrix:
3-
- nodejs_version: "0.10"
4-
- nodejs_version: "0.12"
53
- nodejs_version: "4"
64
- nodejs_version: "5"
75

lib/samsam.js

+4
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@
398398
return arrayContains(object, matcher, match);
399399
}
400400

401+
if (isDate(matcher)) {
402+
return isDate(object) && object.getTime() === matcher.getTime();
403+
}
404+
401405
if (matcher && typeof matcher === "object") {
402406
if (matcher === object) {
403407
return true;

test/samsam-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ if (typeof module === "object" && typeof require === "function") {
423423
}])
424424
);
425425
}
426+
427+
var date = new Date();
428+
var sameDate = new Date(date.getTime());
429+
var anotherDate = new Date(date.getTime() - 10);
430+
pass("date objects with same date", date, sameDate);
431+
fail("date objects with different dates", date, anotherDate);
426432
});
427433

428434
tests("isArguments", function (pass, fail) {

0 commit comments

Comments
 (0)