Version 1
[yaffs-website] / node_modules / es5-shim / tests / spec / s-date.js
1 /* global describe, it, xit, expect, beforeEach, jasmine */
2
3 describe('Date', function () {
4     'use strict';
5
6     var supportsDescriptors = Object.defineProperty && (function () {
7         try {
8             var obj = {};
9             Object.defineProperty(obj, 'x', {
10                 enumerable: false,
11                 value: obj
12             });
13             for (var _ in obj) { // jscs:ignore disallowUnusedVariables
14                 return false;
15             }
16             return obj.x === obj;
17         } catch (e) { /* this is ES3 */
18             return false;
19         }
20     }());
21     var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
22     var has = Object.prototype.hasOwnProperty;
23
24     var negativeDate;
25     beforeEach(function () {
26         var negativeCanned = [
27             {
28                 getTime: -3509827329600292,
29                 getUTCDay: 4,
30                 getDay: 4,
31                 dim: 31
32             },
33             {
34                 getTime: -3509824651200292,
35                 getUTCDay: 0,
36                 getDay: 0,
37                 dim: 29
38             },
39             {
40                 getTime: -3509822145600292,
41                 getUTCDay: 1,
42                 getDay: 1,
43                 dim: 31
44             },
45             {
46                 getTime: -3509819467200292,
47                 getUTCDay: 4,
48                 getDay: 4,
49                 dim: 30
50             },
51             {
52                 getTime: -3509816875200292,
53                 getUTCDay: 6,
54                 getDay: 6,
55                 dim: 31
56             },
57             {
58                 getTime: -3509814196800292,
59                 getUTCDay: 2,
60                 getDay: 2,
61                 dim: 30
62             },
63             {
64                 getTime: -3509811604800292,
65                 getUTCDay: 4,
66                 getDay: 4,
67                 dim: 31
68             },
69             {
70                 getTime: -3509808926400292,
71                 getUTCDay: 0,
72                 getDay: 0,
73                 dim: 31
74             },
75             {
76                 getTime: -3509806248000292,
77                 getUTCDay: 3,
78                 getDay: 3,
79                 dim: 30
80             },
81             {
82                 getTime: -3509803656000292,
83                 getUTCDay: 5,
84                 getDay: 5,
85                 dim: 31
86             },
87             {
88                 getTime: -3509800977600292,
89                 getUTCDay: 1,
90                 getDay: 1,
91                 dim: 30
92             },
93             {
94                 getTime: -3509798385600292,
95                 getUTCDay: 3,
96                 getDay: 3,
97                 dim: 31
98             }
99         ];
100         negativeDate = negativeCanned.map(function (item) {
101             var dateFirst = new Date(item.getTime);
102             var dateLast = new Date(item.getTime + ((item.dim - 1) * 86400000));
103             return {
104                 dates: [dateFirst, dateLast],
105                 days: [1, item.dim],
106                 getUTCDay: [item.getUTCDay, (item.getUTCDay + item.dim - 1) % 7],
107                 getDay: [item.getDay, (item.getDay + item.dim - 1) % 7]
108             };
109         });
110     });
111
112     describe('.now()', function () {
113         it('should be the current time', function () {
114             var before = (new Date()).getTime();
115             var middle = Date.now();
116             var after = (new Date()).getTime();
117             expect(middle).not.toBeLessThan(before);
118             expect(middle).not.toBeGreaterThan(after);
119         });
120     });
121
122     describe('constructor', function () {
123         it('works with standard formats', function () {
124             //    Chrome 19     Opera 12      Firefox 11    IE 9          Safari 5.1.1
125             expect(+new Date('2012-12-31T23:59:59.000Z')).toBe(1356998399000); //    1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
126             expect(+new Date('2012-04-04T05:02:02.170Z')).toBe(1333515722170); //    1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
127             expect(+new Date('2012-04-04T05:02:02.170999Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
128             expect(+new Date('2012-04-04T05:02:02.17Z')).toBe(1333515722170); //     1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
129             expect(+new Date('2012-04-04T05:02:02.1Z')).toBe(1333515722100); //      1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
130             expect(+new Date('2012-04-04T24:00:00.000Z')).toBe(1333584000000); //    NaN           1333584000000 1333584000000 1333584000000 1333584000000
131             expect(+new Date('2012-02-29T12:00:00.000Z')).toBe(1330516800000); //    1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
132             expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); //    1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
133
134             // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
135             expect(new Date('2034-03-01T00:00:00.000Z') -
136                 new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); //          86400001      86400001      86400001      86400001             1
137
138         });
139
140         ifSupportsDescriptorsIt('is not enumerable', function () {
141             expect(Object.keys(new Date())).not.toContain('constructor');
142         });
143
144         it('works as a function', function () {
145             var zeroDate = Date(0);
146             expect(zeroDate).toBe(String(zeroDate));
147             var value = Date(1441705534578);
148             expect(value).toBe(String(value));
149         });
150
151         it('fixes this Safari 8/9 bug', function () {
152             var offset = new Date(1970).getTimezoneOffset() * 60e3;
153
154             var timestamp = 2147483647; // Math.pow(2, 31) - 1
155             var date = new Date(1970, 0, 1, 0, 0, 0, timestamp);
156             var expectedTimestamp = timestamp + offset;
157             expect(date.getTime()).toBe(expectedTimestamp);
158
159             var brokenTimestamp = 2147483648; // Math.pow(2, 31)
160             var brokenDate = new Date(1970, 0, 1, 0, 0, 0, brokenTimestamp);
161             var expectedBrokenTimestamp = brokenTimestamp + offset;
162             expect(brokenDate.getTime()).toBe(expectedBrokenTimestamp); // NaN in Safari 8/9
163
164             var veryBrokenTS = 1435734000000;
165             var veryBrokenDate = new Date(1970, 0, 1, 0, 0, 0, veryBrokenTS);
166             var largeDate = new Date('Wed Jul 01 2015 07:00:00 GMT-0700 (PDT)');
167             var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3);
168             expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9
169         });
170
171         it('works with a Date object', function () {
172             var date = new Date(1456297712984);
173             var copiedDate = new Date(date);
174             expect(date).not.toBe(copiedDate);
175             expect(copiedDate.getTime()).toBe(date.getTime());
176             expect(+copiedDate).toBe(+date);
177             expect(String(copiedDate)).toBe(String(date));
178         });
179     });
180
181     describe('.parse()', function () {
182         // TODO: Write the rest of the test.
183
184         ifSupportsDescriptorsIt('is not enumerable', function () {
185             expect(Object.getOwnPropertyDescriptor(Date, 'parse').enumerable).toBe(false);
186         });
187
188         it('should be an invalid date', function () {
189             //            Chrome 19     Opera 12      Firefox 11    IE 9          Safari 5.1.1
190             expect(Date.parse('2012-11-31T23:59:59.000Z')).toBeFalsy(); //            1354406399000 NaN           NaN           1354406399000 NaN
191             expect(Date.parse('2012-12-31T23:59:60.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           1356998400000
192             expect(Date.parse('2012-04-04T24:00:00.500Z')).toBeFalsy(); //            NaN           NaN           1333584000500 1333584000500 NaN
193             expect(Date.parse('2012-12-31T10:08:60.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           1356948540000
194             expect(Date.parse('2012-13-01T12:00:00.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
195             expect(Date.parse('2012-12-32T12:00:00.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
196             expect(Date.parse('2012-12-31T25:00:00.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
197             expect(Date.parse('2012-12-31T24:01:00.000Z')).toBeFalsy(); //            NaN           NaN           NaN           1356998460000 NaN
198             expect(Date.parse('2012-12-31T12:60:00.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
199             expect(Date.parse('2012-12-31T12:00:60.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           1356955260000
200             expect(Date.parse('2012-00-31T23:59:59.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
201             expect(Date.parse('2012-12-00T23:59:59.000Z')).toBeFalsy(); //            NaN           NaN           NaN           NaN           NaN
202             expect(Date.parse('2011-02-29T12:00:00.000Z')).toBeFalsy(); //            1298980800000 NaN           NaN           1298980800000 NaN
203         });
204
205         it('should work', function () {
206             var dates = {
207                 //    Chrome 19     Opera 12      Firefox 11    IE 9          Safari 5.1.1  Safari 8
208                 '2012-12-31T23:59:59.000Z': 1356998399000, //    1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
209                 '2012-04-04T05:02:02.170Z': 1333515722170, //    1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
210                 '2012-04-04T05:02:02.170999Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170.999
211                 '2012-04-04T05:02:02.17Z': 1333515722170, //     1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
212                 '2012-04-04T05:02:02.1Z': 1333515722100, //      1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
213                 '2012-04-04T24:00:00.000Z': 1333584000000, //    NaN           1333584000000 1333584000000 1333584000000 1333584000000 1333584000000
214                 '2012-02-29T12:00:00.000Z': 1330516800000, //    1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
215                 '2011-03-01T12:00:00.000Z': 1298980800000 //     1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
216             };
217             for (var str in dates) {
218                 if (has.call(dates, str)) {
219                     expect(Math.floor(Date.parse(str))).toBe(dates[str]);
220                 }
221             }
222
223             // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
224             expect(Date.parse('2034-03-01T00:00:00.000Z') -
225                 Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); //         86400001      86400001      86400001      86400001             1
226
227         });
228
229         it('fixes a Safari 8/9 bug with parsing in UTC instead of local time', function () {
230             var offset = new Date('2015-07-01').getTimezoneOffset() * 60e3;
231             expect(Date.parse('2015-07-01T00:00:00')).toBe(1435708800000 + offset); // Safari 8/9 give NaN
232         });
233
234         it('should support extended years', function () {
235             //    Chrome 19     Opera 12      Firefox 11    IE 9          Safari 5.1.1
236             expect(Date.parse('0000-01-01T00:00:00.000Z')).toBe(-621672192e5); //   -621672192e5  -621672192e5  -621672192e5  -621672192e5  -621672192e5
237             expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-621355968e5); //       -621355968e5  -621355968e5  -621355968e5   8.64e15      -621355968e5
238             expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15); //      8.64e15       NaN           8.64e15       8.64e15       8.64e15
239             expect(Date.parse('-271821-04-20T00:00:00.000Z')).toBe(-8.64e15); //    -8.64e15       NaN          -8.64e15      -8.64e15      -8.6400000864e15
240             expect(Date.parse('+275760-09-13T00:00:00.001Z')).toBeFalsy(); //        NaN           NaN           NaN           8.64e15 + 1   8.64e15 + 1
241             expect(Date.parse('-271821-04-19T23:59:59.999Z')).toBeFalsy(); //        NaN           NaN           NaN          -8.64e15 - 1  -8.6400000864e15 - 1
242             expect(Date.parse('+033658-09-27T01:46:40.000Z')).toBe(1e15); //         1e15          NaN           1e15          1e15          9999999136e5
243             expect(Date.parse('-000001-01-01T00:00:00Z')).toBe(-621987552e5); //    -621987552e5   NaN          -621987552e5  -621987552e5  -621987552e5
244             expect(Date.parse('+002009-12-15T00:00:00Z')).toBe(12608352e5); //       12608352e5    NaN           12608352e5    12608352e5    12608352e5
245         });
246
247         it('works with timezone offsets', function () {
248             //  Chrome 19   Opera 12     Firefox 11   IE 9             Safari 5.1.1
249             expect(Date.parse('2012-01-29T12:00:00.000+01:00')).toBe(132783480e4); //  132783480e4 132783480e4  132783480e4  132783480e4      132783480e4
250             expect(Date.parse('2012-01-29T12:00:00.000-00:00')).toBe(132783840e4); //  132783840e4 132783840e4  132783840e4  132783840e4      132783840e4
251             expect(Date.parse('2012-01-29T12:00:00.000+00:00')).toBe(132783840e4); //  132783840e4 132783840e4  132783840e4  132783840e4      132783840e4
252             expect(Date.parse('2012-01-29T12:00:00.000+23:59')).toBe(132775206e4); //  132775206e4 132775206e4  132775206e4  132775206e4      132775206e4
253             expect(Date.parse('2012-01-29T12:00:00.000-23:59')).toBe(132792474e4); //  132792474e4 132792474e4  132792474e4  132792474e4      132792474e4
254             expect(Date.parse('2012-01-29T12:00:00.000+24:00')).toBeFalsy(); //        NaN         1327752e6    NaN          1327752000000    1327752000000
255             expect(Date.parse('2012-01-29T12:00:00.000+24:01')).toBeFalsy(); //        NaN         NaN          NaN          1327751940000    1327751940000
256             expect(Date.parse('2012-01-29T12:00:00.000+24:59')).toBeFalsy(); //        NaN         NaN          NaN          1327748460000    1327748460000
257             expect(Date.parse('2012-01-29T12:00:00.000+25:00')).toBeFalsy(); //        NaN         NaN          NaN          NaN              NaN
258             expect(Date.parse('2012-01-29T12:00:00.000+00:60')).toBeFalsy(); //        NaN         NaN          NaN          NaN              NaN
259             expect(Date.parse('-271821-04-20T00:00:00.000+00:01')).toBeFalsy(); //     NaN         NaN          NaN         -864000000006e4 -864000008646e4
260             expect(Date.parse('-271821-04-20T00:01:00.000+00:01')).toBe(-8.64e15); // -8.64e15     NaN         -8.64e15     -8.64e15        -864000008640e4
261
262             // When time zone is missed, local offset should be used (ES 5.1 bug)
263             // see https://bugs.ecmascript.org/show_bug.cgi?id=112
264             var tzOffset = Number(new Date(1970, 0));
265             // same as (new Date().getTimezoneOffset() * 60000)
266             expect(Date.parse('1970-01-01T00:00:00')).toBe(tzOffset); //              tzOffset    0            0            0               NaN
267         });
268
269         it('should be able to coerce to a number', function () {
270             var actual = Number(new Date(1970, 0));
271             var expected = parseInt(actual, 10);
272             expect(actual).toBeDefined();
273             expect(actual).toBe(expected);
274             expect(isNaN(actual)).toBeFalsy();
275         });
276
277     });
278
279     describe('#toString()', function () {
280         var actual;
281
282         beforeEach(function () {
283             actual = (new Date(1970, 0)).toString();
284         });
285
286         it('should show correct date info for ' + actual, function () {
287             expect(actual).toMatch(/1970/);
288             expect(actual).toMatch(/jan/i);
289             expect(actual).toMatch(/thu/i);
290             expect(actual).toMatch(/00:00:00/);
291         });
292     });
293
294     describe('#valueOf()', function () {
295         // Note that new Date(1970, 0).valueOf() is 0 in UTC timezone.
296         // Check check that it's a number (and an int), not that it's "truthy".
297         var actual;
298
299         beforeEach(function () {
300             actual = (new Date(1970, 0)).valueOf();
301         });
302         it('should give a numeric value', function () {
303             expect(typeof actual).toBe('number');
304         });
305         it('should not be NaN', function () {
306             expect(isNaN(actual)).toBe(false);
307         });
308         it('should give an int value', function () {
309             expect(actual).toBe(Math.floor(actual));
310         });
311     });
312
313     describe('#getUTCDate()', function () {
314         it('should return the right value for negative dates', function () {
315             // Opera 10.6/11.61/Opera 12 bug
316             negativeDate.forEach(function (item) {
317                 item.dates.forEach(function (date, index) {
318                     expect(date.getUTCDate()).toBe(item.days[index], date);
319                 });
320             });
321         });
322     });
323
324     describe('#getUTCDay()', function () {
325         it('should return the right value for negative dates', function () {
326             negativeDate.forEach(function (item) {
327                 item.dates.forEach(function (date, index) {
328                     expect(date.getUTCDay()).toBe(item.getUTCDay[index]);
329                 });
330             });
331         });
332     });
333
334     describe('#getUTCFullYear()', function () {
335         it('should return the right value for negative dates', function () {
336             // Opera 10.6/11.61/Opera 12 bug
337             negativeDate.forEach(function (item) {
338                 item.dates.forEach(function (date) {
339                     expect(date.getUTCFullYear()).toBe(-109252);
340                 });
341             });
342         });
343     });
344
345     describe('#getUTCMonth()', function () {
346         it('should return the right value for negative dates', function () {
347             // Opera 10.6/11.61/Opera 12 bug
348             negativeDate.forEach(function (item, index) {
349                 item.dates.forEach(function (date) {
350                     expect(date.getUTCMonth()).toBe(index);
351                 });
352             });
353         });
354
355         it('should return correct values', function () {
356             expect(new Date(8.64e15).getUTCMonth()).toBe(8);
357             expect(new Date(0).getUTCMonth()).toBe(0);
358         });
359     });
360
361     describe('#getUTCHours()', function () {
362         it('should return the right value for negative dates', function () {
363             negativeDate.forEach(function (item) {
364                 item.dates.forEach(function (date) {
365                     expect(date.getUTCHours()).toBe(11);
366                 });
367             });
368         });
369     });
370
371     describe('#getUTCMinutes()', function () {
372         it('should return the right value for negative dates', function () {
373             negativeDate.forEach(function (item) {
374                 item.dates.forEach(function (date) {
375                     expect(date.getUTCMinutes()).toBe(59);
376                 });
377             });
378         });
379     });
380
381     describe('#getUTCSeconds()', function () {
382         it('should return the right value for negative dates', function () {
383             negativeDate.forEach(function (item) {
384                 item.dates.forEach(function (date) {
385                     expect(date.getUTCSeconds()).toBe(59);
386                 });
387             });
388         });
389     });
390
391     describe('#getUTCMilliseconds()', function () {
392         it('should return the right value for negative dates', function () {
393             // Opera 10.6/11.61/Opera 12 bug
394             negativeDate.forEach(function (item) {
395                 item.dates.forEach(function (date) {
396                     expect(date.getUTCMilliseconds()).toBe(708);
397                 });
398             });
399         });
400     });
401
402     describe('#getDate()', function () {
403         it('should return the right value for negative dates', function () {
404             negativeDate.forEach(function (item) {
405                 item.dates.forEach(function (date, index) {
406                     expect(date.getDate()).toBe(item.days[index]);
407                 });
408             });
409         });
410     });
411
412     describe('#getDay()', function () {
413         it('should return the right value for negative dates', function () {
414             negativeDate.forEach(function (item) {
415                 item.dates.forEach(function (date, index) {
416                     expect(date.getDay()).toBe(item.getDay[index]);
417                 });
418             });
419         });
420     });
421
422     describe('#getFullYear()', function () {
423         it('should return the right value for negative dates', function () {
424             // Opera 10.6/11.61/Opera 12 bug
425             negativeDate.forEach(function (item) {
426                 item.dates.forEach(function (date) {
427                     expect(date.getFullYear()).toBe(-109252);
428                 });
429             });
430         });
431     });
432
433     describe('#getMonth()', function () {
434         it('should return the right value for negative dates', function () {
435             // Opera 10.6/11.61/Opera 12 bug
436             negativeDate.forEach(function (item, index) {
437                 item.dates.forEach(function (date) {
438                     expect(date.getMonth()).toBe(index);
439                 });
440             });
441         });
442     });
443
444     describe('#getHours()', function () {
445         it('should return the right value for negative dates', function () {
446             negativeDate.forEach(function (item) {
447                 item.dates.forEach(function (date) {
448                     expect(date.getHours() + Math.floor(date.getTimezoneOffset() / 60)).toBe(11);
449                 });
450             });
451         });
452     });
453
454     describe('#getMinutes()', function () {
455         it('should return the right value for negative dates', function () {
456             negativeDate.forEach(function (item) {
457                 item.dates.forEach(function (date) {
458                     var off = date.getTimezoneOffset();
459                     var offHours = Math.floor(off / 60);
460                     var offMins = off - offHours * 60;
461                     expect(date.getMinutes() + offMins).toBe(59);
462                 });
463             });
464         });
465     });
466
467     describe('#getSeconds()', function () {
468         it('should return the right value for negative dates', function () {
469             negativeDate.forEach(function (item) {
470                 item.dates.forEach(function (date) {
471                     expect(date.getSeconds()).toBe(59);
472                 });
473             });
474         });
475     });
476
477     describe('#getMilliseconds()', function () {
478         it('should return the right value for negative dates', function () {
479             // Opera 10.6/11.61/Opera 12 bug
480             negativeDate.forEach(function (item) {
481                 item.dates.forEach(function (date) {
482                     expect(date.getMilliseconds()).toBe(708);
483                 });
484             });
485         });
486     });
487
488     describe('#toISOString()', function () {
489         // TODO: write the rest of the test.
490
491         it('should support extended years', function () {
492             expect(new Date(-62198755200000).toISOString().indexOf('-000001-01-01')).toBe(0);
493             expect(new Date(8.64e15).toISOString().indexOf('+275760-09-13')).toBe(0);
494         });
495
496         it('should return correct dates', function () {
497             expect(new Date(-1).toISOString()).toBe('1969-12-31T23:59:59.999Z'); // Safari 5.1.5 "1969-12-31T23:59:59.-01Z"
498             negativeDate.forEach(function (item, index) {
499                 var m = index + 1;
500                 item.dates.forEach(function (date, idx) {
501                     var d = item.days[idx];
502                     expect(date.toISOString()).toBe('-109252-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + 'T11:59:59.708Z'); // Opera 11.61/Opera 12 bug with Date#getUTCMonth
503                 });
504             });
505         });
506
507     });
508
509     describe('#toUTCString()', function () {
510         it('should return correct dates', function () {
511             expect(new Date(-1509842289600292).toUTCString()).toBe('Mon, 01 Jan -45875 11:59:59 GMT');
512         });
513     });
514
515     describe('#toDateString()', function () {
516         it('should return correct dates', function () {
517             expect(new Date(-1509842289600292).toDateString()).toBe('Mon Jan 01 -45875');
518         });
519     });
520
521     describe('#toString()', function () {
522         it('should return correct dates', function () {
523             var actual = new Date(1449662400000).toString();
524             var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/;
525             expect(re.test(actual)).toBe(true, actual);
526         });
527     });
528
529     describe('#toJSON()', function () {
530
531         // Opera 11.6x/12 bug
532         it('should call toISOString', function () {
533             var date = new Date(0);
534             date.toISOString = function () {
535                 return 1;
536             };
537             expect(date.toJSON()).toBe(1);
538         });
539
540         it('should return null for not finite dates', function () {
541             var date = new Date(NaN),
542                 json;
543             try {
544                 json = date.toJSON();
545             } catch (e) {
546                 /* invalid json */
547                 expect(e).not.toEqual(jasmine.any(Error));
548             }
549             expect(json).toBe(null);
550         });
551
552         it('should return the isoString when stringified', function () {
553             var date = new Date();
554             expect(JSON.stringify(date.toISOString())).toBe(JSON.stringify(date));
555         });
556     });
557
558 });