Sha256: dbeb42e4b280d940a48d0d9e9bce1c891fe78f5b7d352d24e46395bf7fa4d0e6

Contents?: true

Size: 1.38 KB

Versions: 41

Compression:

Stored size: 1.38 KB

Contents

'use strict';

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

test('not Strings', function (t) {
	t.notOk(isString(), 'undefined is not String');
	t.notOk(isString(null), 'null is not String');
	t.notOk(isString(false), 'false is not String');
	t.notOk(isString(true), 'true is not String');
	t.notOk(isString([]), 'array is not String');
	t.notOk(isString({}), 'object is not String');
	t.notOk(isString(function () {}), 'function is not String');
	t.notOk(isString(/a/g), 'regex literal is not String');
	t.notOk(isString(new RegExp('a', 'g')), 'regex object is not String');
	t.notOk(isString(new Date()), 'new Date() is not String');
	t.notOk(isString(42), 'number is not String');
	t.notOk(isString(Object(42)), 'number object is not String');
	t.notOk(isString(NaN), 'NaN is not String');
	t.notOk(isString(Infinity), 'Infinity is not String');
	t.end();
});

test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
	var fakeString = {
		toString: function () { return '7'; },
		valueOf: function () { return '42'; }
	};
	fakeString[Symbol.toStringTag] = 'String';
	t.notOk(isString(fakeString), 'fake String with @@toStringTag "String" is not String');
	t.end();
});

test('Strings', function (t) {
	t.ok(isString('foo'), 'string primitive is String');
	t.ok(isString(Object('foo')), 'string object is String');
	t.end();
});

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.50 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.49 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.48 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.47 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.46 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.45 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.44 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.43 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.42 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.41 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.40 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.39 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.38 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.32 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.31 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.30 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.29 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.28 node_modules/is-string/test/index.js
immosquare-cleaner-0.1.27 node_modules/is-string/test/index.js