Sha256: 87df220dece6045708c334feab339a5972c0ef4383d822eb134678458736b1f4

Contents?: true

Size: 1.13 KB

Versions: 50

Compression:

Stored size: 1.13 KB

Contents

'use strict';

var test = require('tape');
var isDate = require('../');
var hasToStringTag = require('has-tostringtag/shams')();

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: !hasToStringTag }, 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

50 entries across 50 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.59 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.58 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.57 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.56 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.55 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.54 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.53 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.52 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.51 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.50 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.49 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.48 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.47 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.46 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.45 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.44 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.43 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.42 node_modules/is-date-object/test/index.js
immosquare-cleaner-0.1.41 node_modules/is-date-object/test/index.js