source: imaps-frontend/node_modules/is-date-object/test/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var isDate = require('../');
5var hasToStringTag = require('has-tostringtag/shams')();
6
7test('not Dates', function (t) {
[79a0317]8 // @ts-expect-error
[d565449]9 t.notOk(isDate(), 'undefined is not Date');
10 t.notOk(isDate(null), 'null is not Date');
11 t.notOk(isDate(false), 'false is not Date');
12 t.notOk(isDate(true), 'true is not Date');
13 t.notOk(isDate(42), 'number is not Date');
14 t.notOk(isDate('foo'), 'string is not Date');
15 t.notOk(isDate([]), 'array is not Date');
16 t.notOk(isDate({}), 'object is not Date');
17 t.notOk(isDate(function () {}), 'function is not Date');
18 t.notOk(isDate(/a/g), 'regex literal is not Date');
19 t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date');
20 t.end();
21});
22
23test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
24 var realDate = new Date();
[79a0317]25 /** @type {{ toString(): unknown; valueOf(): unknown; [Symbol.toStringTag]?: string; }} */
[d565449]26 var fakeDate = {
27 toString: function () { return String(realDate); },
28 valueOf: function () { return realDate.getTime(); }
29 };
30 fakeDate[Symbol.toStringTag] = 'Date';
31 t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date');
32 t.end();
33});
34
35test('Dates', function (t) {
36 t.ok(isDate(new Date()), 'new Date() is Date');
37 t.end();
38});
Note: See TracBrowser for help on using the repository browser.