Skip to content

Commit

Permalink
Add test for valueOf behaviour with invalid moments (#1075)
Browse files Browse the repository at this point in the history
Co-authored-by: Tmk <i@tmk.im>
  • Loading branch information
gilmoreorless and tmkx committed Dec 29, 2023
1 parent 341beac commit ece926a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/moment-timezone/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,19 @@ exports.default = {
'resetting default timezone should not affect existing moments'
);
t.done();
},
valueOf : function (t) {
moment.tz.setDefault();
t.ok(
Number.isNaN(moment('2023/10/06', ['H', 'HH', 'HH:mm'], true).valueOf()),
'invalid moment should return NaN for .valueOf()'
);
// https://github.com/moment/moment-timezone/issues/1075
moment.tz.setDefault('America/New_York');
t.ok(
Number.isNaN(moment('2023/10/06', ['H', 'HH', 'HH:mm'], true).valueOf()),
'invalid moment with default zone should return NaN for .valueOf()'
);
t.done();
}
};

0 comments on commit ece926a

Please sign in to comment.