chai-datetime
Advanced tools
Comparing version 1.1.0 to 1.1.1
(function(plugin){ | ||
if ( | ||
typeof require === "function" | ||
&& typeof exports === "object" | ||
&& typeof module === "object" | ||
typeof require === "function" && | ||
typeof exports === "object" && | ||
typeof module === "object" | ||
) { | ||
@@ -10,4 +10,4 @@ // NodeJS | ||
} else if ( | ||
typeof define === "function" | ||
&& define.amd | ||
typeof define === "function" && | ||
define.amd | ||
) { | ||
@@ -23,2 +23,12 @@ // AMD | ||
}(function(chai, utils){ | ||
chai.datetime = chai.datetime || {}; | ||
chai.datetime.formatDate = function(date) { | ||
return date.toDateString(); | ||
}; | ||
chai.datetime.formatTime = function(time) { | ||
return time; | ||
}; | ||
chai.Assertion.addChainableMethod('equalTime', function(time) { | ||
@@ -51,4 +61,4 @@ var expected = time.getTime(), | ||
actual.getUTCFullYear <= date.getUTCFullYear && actual.getUTCMonth() <= date.getUTCMonth() && actual.getUTCDate() < date.getUTCDate(), | ||
'expected ' + actual.toDateString() + ' to be before ' + date.toDateString(), | ||
'expected ' + actual.toDateString() + ' not to be before ' + date.toDateString() | ||
'expected ' + chai.datetime.formatDate(actual) + ' to be before ' + chai.datetime.formatDate(date), | ||
'expected ' + chai.datetime.formatDate(actual) + ' not to be before ' + chai.datetime.formatDate(date) | ||
); | ||
@@ -62,4 +72,4 @@ }); | ||
actual.getUTCFullYear >= date.getUTCFullYear && actual.getUTCMonth() >= date.getUTCMonth() && actual.getUTCDate() > date.getUTCDate(), | ||
'expected ' + actual.toDateString() + ' to be after ' + date.toDateString(), | ||
'expected ' + actual.toDateString() + ' not to be after ' + date.toDateString() | ||
'expected ' + chai.datetime.formatDate(actual) + ' to be after ' + chai.datetime.formatDate(date), | ||
'expected ' + chai.datetime.formatDate(actual) + ' not to be after ' + chai.datetime.formatDate(date) | ||
); | ||
@@ -73,4 +83,4 @@ }); | ||
actual.getTime() < time.getTime(), | ||
'expected ' + actual + ' to be before ' + time, | ||
'expected ' + actual + ' not to be before ' + time | ||
'expected ' + chai.datetime.formatTime(actual) + ' to be before ' + chai.datetime.formatTime(time), | ||
'expected ' + chai.datetime.formatTime(actual) + ' not to be before ' + chai.datetime.formatTime(time) | ||
); | ||
@@ -84,4 +94,4 @@ }); | ||
actual.getTime() > time.getTime(), | ||
'expected ' + actual + ' to be after ' + time, | ||
'expected ' + actual + ' not to be after ' + time | ||
'expected ' + chai.datetime.formatTime(actual) + ' to be after ' + chai.datetime.formatTime(time), | ||
'expected ' + chai.datetime.formatTime(actual) + ' not to be after ' + chai.datetime.formatTime(time) | ||
); | ||
@@ -95,48 +105,48 @@ }); | ||
new chai.Assertion(val, msg).to.be.equalDate(exp); | ||
} | ||
}; | ||
assert.notEqualDate = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.not.be.equalDate(exp); | ||
} | ||
}; | ||
assert.beforeDate = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.be.beforeDate(exp); | ||
} | ||
}; | ||
assert.notBeforeDate = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.not.be.beforeDate(exp); | ||
} | ||
}; | ||
assert.afterDate = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.be.afterDate(exp); | ||
} | ||
}; | ||
assert.notAfterDate = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).not.to.be.afterDate(exp); | ||
} | ||
}; | ||
assert.equalTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.be.equalTime(exp); | ||
} | ||
}; | ||
assert.notEqualTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.not.be.equalTime(exp); | ||
} | ||
}; | ||
assert.beforeTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.be.beforeTime(exp); | ||
} | ||
}; | ||
assert.notBeforeTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).not.to.be.beforeTime(exp); | ||
} | ||
}; | ||
assert.afterTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.be.afterTime(exp); | ||
} | ||
}; | ||
assert.notAfterTime = function(val, exp, msg) { | ||
new chai.Assertion(val, msg).to.not.be.afterTime(exp); | ||
} | ||
}; | ||
})); |
{ | ||
"name": "chai-datetime", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"keywords": ["chai", "testing", "jasmine"], | ||
@@ -5,0 +5,0 @@ "description": "date / time comparison matchers for chai", |
@@ -305,3 +305,3 @@ (function(test){ | ||
}).should.fail( | ||
'expected Thu May 30 2013 16:05:00 GMT-0400 (EDT) not to be before Thu May 30 2013 16:05:01 GMT-0400 (EDT)' | ||
'expected ' + chai.datetime.formatTime(this.d1) + ' not to be before ' + chai.datetime.formatTime(this.d2) | ||
); | ||
@@ -324,3 +324,3 @@ }); | ||
}).should.fail( | ||
'expected Thu May 30 2013 16:05:00 GMT-0400 (EDT) to be before Thu May 30 2013 16:05:00 GMT-0400 (EDT)' | ||
'expected ' + chai.datetime.formatTime(this.d1) + ' to be before ' + chai.datetime.formatTime(this.d2) | ||
); | ||
@@ -356,3 +356,3 @@ }); | ||
}).should.fail( | ||
'expected Thu May 30 2013 16:05:01 GMT-0400 (EDT) not to be after Thu May 30 2013 16:05:00 GMT-0400 (EDT)' | ||
'expected ' + chai.datetime.formatTime(this.d1) + ' not to be after ' + chai.datetime.formatTime(this.d2) | ||
); | ||
@@ -375,3 +375,3 @@ }); | ||
}).should.fail( | ||
'expected Thu May 30 2013 16:05:00 GMT-0400 (EDT) to be after Thu May 30 2013 16:05:00 GMT-0400 (EDT)' | ||
'expected ' + chai.datetime.formatTime(this.d1) + ' to be after ' + chai.datetime.formatTime(this.d2) | ||
); | ||
@@ -378,0 +378,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21586
477