File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ export function stringify(value, reducers) {
81
81
break ;
82
82
83
83
case 'Date' :
84
- str = `["Date","${ thing . toISOString ( ) } "]` ;
84
+ const valid = ! isNaN ( thing . getDate ( ) ) ;
85
+ str = `["Date","${ valid ? thing . toISOString ( ) : '' } "]` ;
85
86
break ;
86
87
87
88
case 'RegExp' :
Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ const fixtures = {
109
109
js : 'new Date(1000000000000)' ,
110
110
json : '[["Date","2001-09-09T01:46:40.000Z"]]'
111
111
} ,
112
+ {
113
+ name : 'invalid Date' ,
114
+ value : new Date ( '' ) ,
115
+ js : 'new Date(NaN)' ,
116
+ json : '[["Date",""]]' ,
117
+ validate : ( value ) => {
118
+ assert . ok ( isNaN ( value . valueOf ( ) ) ) ;
119
+ }
120
+ } ,
112
121
{
113
122
name : 'Array' ,
114
123
value : [ 'a' , 'b' , 'c' ] ,
You can’t perform that action at this time.
0 commit comments