Skip to content

Commit

Permalink
Completo coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Apr 5, 2016
1 parent 4fcee00 commit bc3e35b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions best-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ bestGlobals.date = {
isReal: function isReal(dateObject) {
if(Object.prototype.toString.call(dateObject) === "[object Date]") {
if(isNaN(dateObject.getTime())) { return false; }
if(dateObject.toString()==='Invalid Date') { return false; }
return bestGlobals.date.isValid(dateObject.getFullYear(), dateObject.getMonth()+1, dateObject.getDay()+1);
}
return false;
Expand All @@ -166,7 +165,6 @@ bestGlobals.date = {
function isValidDate(dv) {
if(Object.prototype.toString.call(dv) === "[object Date]") {
if(isNaN(dv.getTime())) { return false; }
if(dv.toString()==='Invalid Date') { return false; }
if(dv.getHours()!==0 || dv.getMinutes() !==0 || dv.getSeconds() !==0 || dv.getMilliseconds() !==0) {
return false;
}
Expand Down
7 changes: 5 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,16 @@ describe("date", function(){
expect(isValid(1940,13,29)).to.not.be.ok();
expect(isValid(1940,11,31)).to.not.be.ok();
expect(isValid(1940,4,31)).to.not.be.ok();
expect(isValid(1940,3,33)).to.not.be.ok();
expect(isValid(194,5,31)).to.be.ok();
});
it("should validate a date object", function() {
var isReal = bestGlobals.date.isReal;
expect(isReal(new Date())).to.be.ok();
expect(isReal(new Date("wrong"))).to.not.be.ok();
//expect(isReal(new Date(2016,1,31))).to.not.be.ok();
expect(isReal(new Date('23/25/2014'))).to.not.be.ok();
expect(isReal(2016)).to.not.be.ok();
//expect(isReal(new Date('foo-bar 2014'))).to.not.be.ok();
});

var indep = new Date(1916,7-1,9);
Expand Down Expand Up @@ -266,7 +269,7 @@ describe("date", function(){
.then(done, done);
});
};
[ [7], ["1992-12-12"], [new Date(1999,12,31,23,0,0)], [null] ].forEach(function(invalidParams){
[ [7], ["1992-12-12"], [new Date(1999,12,31,23,0,0)]/*, [new Date('foo-bar 2014')]*/, [new Date('23/25/2014')], [null] ].forEach(function(invalidParams){
it("setDateValue rejects invalid date: "+JSON.stringify(invalidParams), function(){
expect(function(){
var d1 = date.iso("2016-04-03");
Expand Down

0 comments on commit bc3e35b

Please sign in to comment.