Sha256: 0316845f0d0568195a008500c1fd1ad23c7f00e6ec2e5bb875883c26810ee572

Contents?: true

Size: 1.17 KB

Versions: 67

Compression:

Stored size: 1.17 KB

Contents

'use strict';

var test = require('tape');
var isDate = require('./');
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';

test('not Dates', function (t) {
	t.notOk(isDate(), 'undefined is not Date');
	t.notOk(isDate(null), 'null is not Date');
	t.notOk(isDate(false), 'false is not Date');
	t.notOk(isDate(true), 'true is not Date');
	t.notOk(isDate(42), 'number is not Date');
	t.notOk(isDate('foo'), 'string is not Date');
	t.notOk(isDate([]), 'array is not Date');
	t.notOk(isDate({}), 'object is not Date');
	t.notOk(isDate(function () {}), 'function is not Date');
	t.notOk(isDate(/a/g), 'regex literal is not Date');
	t.notOk(isDate(new RegExp('a', 'g')), 'regex object is not Date');
	t.end();
});

test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) {
	var realDate = new Date();
	var fakeDate = { toString: function () { return String(realDate); }, valueOf: function () { return realDate.getTime(); } };
	fakeDate[Symbol.toStringTag] = 'Date';
	t.notOk(isDate(fakeDate), 'fake Date with @@toStringTag "Date" is not Date');
	t.end();
});

test('Dates', function (t) {
	t.ok(isDate(new Date()), 'new Date() is Date');
	t.end();
});

Version data entries

67 entries across 67 versions & 10 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/is-date-object/test.js
disco_app-0.18.2 test/dummy/node_modules/is-date-object/test.js
disco_app-0.16.1 test/dummy/node_modules/is-date-object/test.js
disco_app-0.15.2 test/dummy/node_modules/is-date-object/test.js
disco_app-0.18.4 test/dummy/node_modules/is-date-object/test.js
disco_app-0.18.1 test/dummy/node_modules/is-date-object/test.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/is-date-object/test.js
disco_app-0.14.0 test/dummy/node_modules/is-date-object/test.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/is-date-object/test.js
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/is-date-object/test.js
jester-data-8.0.0 node_modules/is-date-object/test.js
ezii-os-5.2.1 node_modules/is-date-object/test.js
ezii-os-2.0.1 node_modules/is-date-object/test.js
ezii-os-1.1.0 node_modules/is-date-object/test.js
ezii-os-1.0.0 node_modules/is-date-object/test.js
ezii-os-0.0.0.1.0 node_modules/is-date-object/test.js
ezii-os-0.0.0.0.1 node_modules/is-date-object/test.js
govuk_publishing_components-18.0.0 node_modules/is-date-object/test.js
govuk_publishing_components-17.21.0 node_modules/is-date-object/test.js
govuk_publishing_components-17.20.0 node_modules/is-date-object/test.js