-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathes.date.to-iso-string.js
18 lines (18 loc) · 978 Bytes
/
es.date.to-iso-string.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
QUnit.test('Date#toISOString', assert => {
const { toISOString } = Date.prototype;
assert.isFunction(toISOString);
assert.arity(toISOString, 0);
assert.name(toISOString, 'toISOString');
assert.looksNative(toISOString);
assert.nonEnumerable(Date.prototype, 'toISOString');
assert.same(new Date(0).toISOString(), '1970-01-01T00:00:00.000Z');
assert.same(new Date(1e12 + 1).toISOString(), '2001-09-09T01:46:40.001Z');
assert.same(new Date(-5e13 - 1).toISOString(), '0385-07-25T07:06:39.999Z');
const future = new Date(1e15 + 1).toISOString();
const properFuture = future === '+033658-09-27T01:46:40.001Z' || future === '33658-09-27T01:46:40.001Z';
assert.true(properFuture);
const prehistoric = new Date(-1e15 + 1).toISOString();
const properPrehistoric = prehistoric === '-029719-04-05T22:13:20.001Z' || prehistoric === '-29719-04-05T22:13:20.001Z';
assert.true(properPrehistoric);
assert.throws(() => new Date(NaN).toISOString(), RangeError);
});