Skip to content

Commit ece926a

Browse files
gilmoreorlesstmkx
andcommitted
Add test for valueOf behaviour with invalid moments (#1075)
Co-authored-by: Tmk <[email protected]>
1 parent 341beac commit ece926a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/moment-timezone/default.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,19 @@ exports.default = {
7272
'resetting default timezone should not affect existing moments'
7373
);
7474
t.done();
75+
},
76+
valueOf : function (t) {
77+
moment.tz.setDefault();
78+
t.ok(
79+
Number.isNaN(moment('2023/10/06', ['H', 'HH', 'HH:mm'], true).valueOf()),
80+
'invalid moment should return NaN for .valueOf()'
81+
);
82+
// https://github.com/moment/moment-timezone/issues/1075
83+
moment.tz.setDefault('America/New_York');
84+
t.ok(
85+
Number.isNaN(moment('2023/10/06', ['H', 'HH', 'HH:mm'], true).valueOf()),
86+
'invalid moment with default zone should return NaN for .valueOf()'
87+
);
88+
t.done();
7589
}
7690
};

0 commit comments

Comments
 (0)