source: imaps-frontend/node_modules/is-string/test/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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